Sign In Register

How can we help you today?

Start a new topic

Int value returned as Float in JSON response from API

I have an event I am accessing from the HTTP API.  In the cloud code for the event, I'm adding some additional data to a record from a collection before returning it:


        var cursor = queryResults.cursor();

        while (cursor.hasNext()) {

            

            var data = cursor.next().getData();

            

            if (includeRank) {

                data[this.rankInLeagueField] = getPlayerRankFromLeaderboard(data[this.playerIdField], getLBLeaderboardFromLeague(data[this.currentLeagueField]));

            } else {

                data[this.rankInLeagueField] = 100;

            }


            result.push(data);

        }


Parsing JSON when the call is made from the Unity SDK seems to work fine.  However, when I make the web request, the raw text JSON returned is converting 100 to 100.0.  Here is a snippet of the JSON text: "rankInLeague":100.0


Other int values which are stored on the record in the collection return properly as an int w/o a decimal


This is causing problems as it thinks it should be converting a float.  I was wondering what might be causing the API to convert this int to a float and append the decimal on the end and if there is anything I can do to resolve this.


3 people have this question
1 Comment

I am currently having the same issue. Any good way to force the API to not do this?


1 person likes this
Login to post a comment