Hi Luke
For a bit of background, all numbers are doubles in JSON and this is why it's always checking for double. It's assuming the data it's getting has been created from a response..
You're correct in spotting this does not work if you set a value and then try to get it back. I'll get the team to take a look at this to make sure it works in both scenarios.
Gabriel
Hi Gabriel,
That makes sense. I was coming at it from the GSRequestData point of view, and that's where all this unexpected behavior occurs.
At any rate, it's an easy work around for me since all the data are available in the GSData.BaseData dictionary anyway.
Thanks for the quick response!
-Luke
Luke Clark
Three getter methods in the GSData class in the Unity SDK are making an incorrect check against the "double" type before returning a value:
GetFloat:
GetInt:
GetLong:
It appears all three were just copy-and-pasted from the GetDouble method. Unfortunately, due to that "is double" check in the if statement, all three of these getters now return a null value instead of returning the value you put there via one of the AddNumber() overloads.
Also, I noticed the GetNumber(string name) method simply forwards the call to GetLong(). For most users, I doubt this will behave as expected since they may have added an int via the AddNumber() overload, and they might very well expect an int to be returned when calling GetNumber(). But instead, it will return null. I think the GetNumber(string name) method should be removed to avoid confusion.