Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always comes an empty tracking fields array #294

Closed
SilverrainSPB opened this issue May 25, 2023 · 5 comments
Closed

Always comes an empty tracking fields array #294

SilverrainSPB opened this issue May 25, 2023 · 5 comments
Assignees
Labels
Bug This change resolves a defect
Milestone

Comments

@SilverrainSPB
Copy link

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
Copy link
Author

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 Jericho self-assigned this May 25, 2023
@Jericho Jericho added the Bug This change resolves a defect label May 25, 2023
@Jericho Jericho added this to the 0.63.1 milestone May 25, 2023
@Jericho
Copy link
Owner

Jericho commented May 25, 2023

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:

  • If the JSON returned by the Zoom API contains three tracking fields, the resulting array parsed by our custom converter will contain 2 items
  • if the JSON contains two tracking fields, the parsed array will contain 1 item
  • if the JSON contains a single tracking field (I suspect this is your case), the parsed array will be empty

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
Copy link
Author

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

Anyway, thank you for the fast answer and commit.

@Jericho
Copy link
Owner

Jericho commented May 25, 2023

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
Copy link
Owner

Jericho commented May 25, 2023

🎉 This issue has been resolved in version 0.63.1 🎉

The release is available on:

Your GitReleaseManager bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This change resolves a defect
Projects
None yet
Development

No branches or pull requests

2 participants