Starting with version 5.9.3 we've added the JsonParser class to the brainCloud C#/Unity client library in order to improve on memory management and CPU cycles. As part of this change, SuccessCallback and FailureCallback from your API calls now receive the raw Json string values that brainCloud sends. If you are using JsonFx included with the C# client library or Unity's JsonUtility class, you shouldn't have issues with deserializing your Jsons strings during SuccessCallback or FailureCallback.
However, if you're using a Json deserializier that is more strict than JsonFx or JsonUtility with deserializing values, it can lead to situations where the deserialization can fail due to Json number values are no longer being normalized (i.e., converting 1.0 to 1).
For these situations we have added the JSON_COMPATIBILITY_FLAG that should normalize the values again for your callbacks. You can enable this by:
Including
JSON_COMPATIBILITY_FLAGas a conditional compilation symbol or as a Scripting Define symbol in Unity (Player Settings > Other Settings > Scripting Define Symbols).
OR
Edit
BrainCloudCommsdirectly (BrainCloud > Client > BrainCloud > Internal > BrainCloudComms.cs) to uncomment the commented out define forJSON_COMPATIBILITY_FLAGon line 6.Note: If you have the brainCloud C# client library installed in the Package Manager in Unity, you will receive warnings for doing this. It should still compile in your builds but if you go to update the package in the Package Manager this change will be overwritten. Changes like this also won't be able to be committed to Git.
Doing this will remove some of the memory and CPU improvements due to reintroducing old behaviour where Json values were consequently being normalized. The tradeoff is that your Json strings should now be coming through SuccessCallback and FailureCallback and being processed by your custom deserializers as expected before version 5.9.3.
The best course of action would be to develop with the raw Json data in-mind. You can instead have your serializable fields be float or double and have a method to cast them to be int. Or use custom deserialization methods such as JsonConverter for Newtonsoft.Json.Net.
Additionally, you can use JsonParser where it makes sense to not deserialize whole objects. You can use it to grab strings, arrays, or values from anywhere within the Json. Try using it by including the BrainCloud.Common namespace in your script!
