How do I Handle my Json response which contains boolean

0 favourites
  • 4 posts
From the Asset Store
Quick Color Tap!
$2 USD
60% off
A challenging game that needs quick responses!
  • My project has stucked on a point where i am using Json.

    The JSON response from my PHP webservice is as follow :

    {"result":true , "data":"1"}

    but, the problem is i am unable to parse this Json into anything like dictionary or array because all of them take only TEXT or NUMBER. If i parse above JSON into dictionary then the value of result will contain 0 either it is true or false

    so, is there any plugin or any other way to handle such booleans from JSON into C2?

  • Use the browser object with the execjs expression. Say you have that json in a text variable called json.

    You could get it with the expression:

    Browser.execjs(json & ".result")

    That should be enough I'd think. If not then then another idea is to convert the Boolean to a number.

    Do that by changing ".result" to ".result?1:0"

  • sorry for so late,

    thanks R0J0hound.... Browser.execjs() worked for me

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • You can also use str() to fill a dictionary with int values...

    For my map system, I use:

    MapDictionary.Get(str(loopindex-1))

    The values for the map tiles use numbers for some values, and strings for others. Using str() will populate numbers into the value field without any problem.

    ~Sol

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)