Dictionary exported JSON not recognized by JSON parsers

Discussion and feedback on Construct 2

Post » Sun Nov 30, 2014 11:42 pm

Hi,

I explorted into a text file a recursive JSON string I got from a dictionary which includes JSON strings as value. However, JSON parsers have trouble parsing the JSON, including the Mathematica JSON import parser -- sometimes only the first key is recognized, and Mathematica seems to view the whole JSON file as one big string.

any thoughts on that would be appreciated,

Dan
B
8
S
4
G
1
Posts: 205
Reputation: 1,354

Post » Mon Dec 01, 2014 3:04 am

C2 uses wraped json data and only imports wrapped json data. It's really annoying. So c2 can't share. You should try yann's json plugin
B
90
S
18
G
9
Posts: 2,455
Reputation: 15,013

Post » Mon Dec 01, 2014 6:04 am

I have no problem loading regular JSON with the AJAX loader and the JSON I get from the C2 Dictionary and Array objects load up just fine with Newtonsoft... including nested JSON strings. I have also ran the C2 JSON through JSONLint and it looks fine.
B
21
S
5
Posts: 195
Reputation: 1,972

Post » Mon Dec 01, 2014 6:09 am

Thanks @ggibson1

Reloading into C2 works very well for me too. Just when I try to load the JSON into mathematica with Import, the nested JSON isn't recognized as an association, but as a string.

Testing with a number of other JSON parsers, I get similar results.

Perhaps some JSON parsers are more robust to unusual input than others ...

p.s. BTW, i just ran my nested JSON through Lint and it only recognizses the top level keys.
B
8
S
4
G
1
Posts: 205
Reputation: 1,354

Post » Tue Dec 02, 2014 11:40 pm

Perhaps your nested JSON actually is just a string? It isn't really nested JSON unless it is JSON nodes ... JSON nodes encoded into a string isn't nested JSON.
B
21
S
5
Posts: 195
Reputation: 1,972

Post » Wed Dec 03, 2014 5:43 am

Thanks.

Its like this:

UserSession.addKey(gameMetric_n, m)
UserSessions.addKey(Date1, UserSession.asJson)
AllUsersSessions.addKey(userName, UserSessions.asJson)

and a few more like these nested within UserSession

In the end i stored AllUsersSessions.asjson into a text file.

So, the total outcome appears like nested wrapped C2 Json
B
8
S
4
G
1
Posts: 205
Reputation: 1,354

Post » Wed Dec 03, 2014 7:02 am

I am not sure that's what you're referring to, but i had a problem with adding keys with global numbers as keys without stringing them first, they were just not added to dictionary.
Do you see all the data in the dictionary UserSession in debug mode, before you're saving it?
Image
B
71
S
28
G
12
Posts: 515
Reputation: 12,284

Post » Wed Dec 03, 2014 7:38 am

all my keys are strings.
B
8
S
4
G
1
Posts: 205
Reputation: 1,354


Return to Construct 2 General

Who is online

Users browsing this forum: 99Instances2Go, blackhornet, DomenicS, Giggle Software and 4 guests