Hmm, unfortunately I don't believe you can set JsonReader to be able to use a converter. In this case you might want to continue using JsonConvert then.
The first solution I shared where you deserialize & serialize the response to strip out the trailing .0 might be your option here. Additionally, you can also modify your local copy of BrainCloudComms.cs to do this for all responses in-case this situation pops up elsewhere. This will essentially replicate the same behaviour in BC 5.9.2 and older.
If that's the route you take you can modify BrainCloudComms.cs in the HandleResponseBundle function on line 972 like so:
private void HandleResponseBundle(string jsonData) { jsonData = jsonData.Trim(); if ((jsonData.StartsWith("{") && jsonData.EndsWith("}")) || (jsonData.StartsWith("[") && jsonData.EndsWith("]"))) { jsonData = JsonWriter.Serialize(JsonReader.Deserialize(jsonData)); // This will strip any leading .0 for int values, replicating the behaviour from 5.9.2 }We will have to look into if we should have this be an optional flag that can be enabled for compatibility... Do note though that this will mean that a lot of the memory and performance gains from 5.9.3 will be lost.
There is another option though and that's to leverage JsonConverter π
Here's a script that should take floats/doubles during deserialization and convert them to an int. I modified it and tested it, I think it should work for this situation:
using System; using Newtonsoft.Json; /// <summary> /// Converts JSON floating-point numbers (float/double) to int during deserialization. /// </summary> public class FloatToIntJsonConverter : JsonConverter<int> { public override int ReadJson(JsonReader reader, Type objectType, int existingValue, bool hasExistingValue, JsonSerializer serializer) { switch (reader.TokenType) { case JsonToken.Float: return Convert.ToInt32(Math.Round(Convert.ToDouble(reader.Value), MidpointRounding.AwayFromZero)); case JsonToken.Integer: return Convert.ToInt32(reader.Value); case JsonToken.String: string sVal = reader.Value?.ToString() ?? "0"; if (double.TryParse(sVal, out double parsed)) { return Convert.ToInt32(Math.Round(parsed, MidpointRounding.AwayFromZero)); } throw new JsonSerializationException($"Cannot deserialize string to int: {sVal}"); case JsonToken.Null: return 0; default: throw new JsonSerializationException($"Unexpected token when tryign to deserialize as int: {reader.TokenType}"); } } public override void WriteJson(JsonWriter writer, int value, JsonSerializer serializer) { writer.WriteValue(value); } }You can apply this to any specific problematic int like so:
public class ScoreData { [JsonConverter(typeof(FloatToIntJsonConverter))] public int tier; }Of course you can also apply it globally, but that might be a bit riskier to do π Also note that this script will round floats/doubles to the nearest whole number so if you end up using it make sure to keep that in-mind (or feel free to modify it to suit your needs).
Let us know if either of these work out for you!