Parsing Json

Get help using Construct 2

Post » Thu Dec 29, 2011 11:33 am

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.mikepixie2011-12-29 11:43:26
B
16
S
2
G
4
Posts: 67
Reputation: 3,295

Post » Thu Dec 29, 2011 12:15 pm

Than read the manual entry about system expressions.
That should turn noobness to knowledge.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,998
Reputation: 57,791

Post » Thu Dec 29, 2011 12:56 pm

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.htmlYann2011-12-29 12:57:16
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Thu Dec 29, 2011 3:53 pm

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
B
16
S
2
G
4
Posts: 67
Reputation: 3,295

Post » Fri Jan 06, 2012 6:44 pm

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.
B
3
G
2
Posts: 9
Reputation: 1,143

Post » Fri Jan 06, 2012 10:49 pm

The CSV plugin can also read JSON strings.
Moderator
B
87
S
32
G
33
Posts: 3,005
Reputation: 27,397

Post » Thu Jan 26, 2012 8:56 am

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.
B
16
S
2
G
4
Posts: 67
Reputation: 3,295


Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 20 guests