Parsing Json

0 favourites
  • 7 posts
  • Hi everyone

    I have been using Scirra for a little while and there is something that vexes me.

    I can retrieve a json object with ajax no problem but I am a little confused as to how to parse the object to make the data more useable.

    I have searched and can see there has been no real answer to this on the forums. Does anyone have any advice or a wee tutotial I could check out.

    Thanks

    Mike

    EDIT: I have read that it can be done with the tokenat but my noobness with construct expressions is blocking me.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Than read the manual entry about system expressions.

    That should turn noobness to knowledge.

  • Parsing a complexe JSON string with only c2 string manipulation functions might be a bit overkill.

    JSON itself handle such thing as object, you won't really need in c2.

    (Unless you do complicated stuff inside custom made plugins maybe)

    My advice: use something a bit simpler like CSV, there's even a plugin for that : http://www.scirra.com/forum/plugin-csv_topic46096.html

  • Cool, the system expressions manual shall be my bedtime reading tonight, thanks for that.

    I would rather use JSON than csv's as most of the API's I want to work with return JSON and I would rather just work with JSON directly.

    Thanks for the help :D

  • So did you come up with anything good?

    In my side project, I have only one single huge JSON object with array of arrays of objects which I serialize it on server (java), since I know the internal data structure of the object, I can deserialize its fields into more meaningful js variables.

  • The CSV plugin can also read JSON strings.

  • Heya, sorry I have not responded to this thread in a while. Been a full time dad for a few weeks and so have only had late evenings to work.

    I have not yet tried to directly parse json in the app itself but am using tokenat and using my flask backend to do the hard parsing work for now. Fortunately the api I am using is not very involved.

    I am interested in how the CSV plugin can be used to parse json though as that could indeed be very helpful. I will keep you guys informed.

    I have also been playing with the idea of using the calljs plugin to call some custom js that deals with specific bits of json.

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