Jericho / ZoomNet

.NET client library for the Zoom.us REST API v2
MIT License
69 stars 46 forks source link

Always comes an empty tracking fields array #294

Closed SilverrainSPB closed 1 year ago

SilverrainSPB commented 1 year ago

When calling the ZoomClient method.Meetings.GetAsync always receives an empty TrackingFields array. The problem clearly lies in the parsing of the incoming response.

SilverrainSPB commented 1 year ago

The problem is that the first StartObject token is always skipped due to calling reader.Read() before the loop and calling it again in the loop condition. Therefore, you can simply remove reader.Read() before the loop and move the reader.Read() call to the beginning of the loop condition.

I can't create a branch and pull request with the necessary fix. But Read method of KeyValuePairConverter should look like this:

        public override KeyValuePair<string, string>[] Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
        {
            if (reader.TokenType == JsonTokenType.StartArray)
            {
                var values = new List<KeyValuePair<string, string>>();

                while (reader.Read() && (reader.TokenType != JsonTokenType.EndArray))
                {
                    if (reader.TokenType == JsonTokenType.StartObject)
                    {
                        var fieldName = string.Empty;
                        var fieldValue = string.Empty;

                        while ((reader.TokenType != JsonTokenType.EndObject) && reader.Read())
                        {
                            if (reader.TokenType == JsonTokenType.PropertyName)
                            {
                                var propertyName = reader.GetString();
                                reader.Read();

                                if (propertyName == _keyFieldName) fieldName = reader.GetString();
                                else if (propertyName == _valueFieldName) fieldValue = reader.GetString();
                            }
                        }

                        values.Add(new KeyValuePair<string, string>(fieldName, fieldValue));
                    }
                }

                return values.ToArray();
            }

            throw new Exception("Unable to read Key/Value pair");
        }

Please check it and release the new version of the ZoomNet lib as soon as it possible. I'm realy looking forward to it. :)

Jericho commented 1 year ago

Thanks for reporting this issue. I was able to confirm there's an issue in the custom JSON converter that causes the first item in the array to be skipped. In other words:

So the resulting array is not always empty, but if your JSON only contains a single tracking field I can see how you would reach this conclusion.

Regardless, this bug needs to be fixed.

SilverrainSPB commented 1 year ago

That's right, I tested this method when using a single tracking_field.

Anyway, thank you for the fast answer and commit.

Jericho commented 1 year ago

Package is being built as I write this. Will be on Nuget shortly (probably in an hour or so... depending how long it takes for Nuget to index the package)

Jericho commented 1 year ago

:tada: This issue has been resolved in version 0.63.1 :tada:

The release is available on:

Your GitReleaseManager bot :package::rocket: