How do I load data from Json string

Get help using Construct 2

Post » Tue Nov 25, 2014 10:46 pm

the problem is that my old capx files with array loading from Json string suddenly stop working//// They were working before, but now i have a problem on all browsers :( Maybe i miss somsing i update construct for 188-189 and today for 190 versions.

p.s sry for my Eng.
You do not have the required permissions to view the files attached to this post.
ImageImageImage
B
42
S
17
G
3
Posts: 155
Reputation: 5,096

Post » Tue Nov 25, 2014 11:01 pm

Hi @Nagval333 did it stop working after upgrading to a beta version?
Image
B
9
S
3
G
1
Posts: 346
Reputation: 1,560

Post » Tue Nov 25, 2014 11:22 pm

I was working always with a beta versions (maybe it's a mistake///iam pretty newbie in all this), but yes i regularly upload it, and last time i used it in 186 version and it work fine/// Now 188 and 190 make problem. The interesting thing that arrays uploading from AJAX ( json files ) still perfect working.
ImageImageImage
B
42
S
17
G
3
Posts: 155
Reputation: 5,096

Post » Tue Nov 25, 2014 11:31 pm

I'm pretty much a noob too and I read that the beta versions are really intended only for people with more experience who can cope with things going wrong (as they'll know that their own code is right) - as I understand it, you and I are better off sticking with the latest "stable" version (r184)
Image
B
9
S
3
G
1
Posts: 346
Reputation: 1,560

Post » Tue Nov 25, 2014 11:46 pm

Hey - sorry, I've just checked and see that r190 was released yesterday as a stable version!
Image
B
9
S
3
G
1
Posts: 346
Reputation: 1,560

Post » Wed Nov 26, 2014 12:04 am

It's the tabs in the string that are causing the problem.
B
55
S
29
G
19
Posts: 1,520
Reputation: 25,630

Post » Wed Nov 26, 2014 9:23 am

"ramones" can you (or someone else) show me what i have to change for make it work? All caps that use this function stop working, its a bit of sad.
ImageImageImage
B
42
S
17
G
3
Posts: 155
Reputation: 5,096

Post » Wed Nov 26, 2014 9:34 am

Your JSON string has [TAB] characters in it:
Code: Select all
"{
   ""c2array"":true,
   ""size"":[3,7,1],
   ""data"":[
      [[0],[0],[0], [0],[0],[0],[0]],
      [[1],[-1],[-1],[-1],[-1],[14],[26]],
      [[2],[30],[10],[8],[-1],[-1],[-1]],
      [[3],[0],[-1],[-1],[-1],[-1],[-1]]
   ]
}"


I guess you copy/pasted it from another editor. If you remove the tabs (replace them with spaces) it works.

Maybe make a bug report if it worked before.
B
55
S
29
G
19
Posts: 1,520
Reputation: 25,630

Post » Wed Nov 26, 2014 10:03 am

Thank you very much "ramon", now its work. Honesty i have no idea how to write this correct from start, i just copy/paste this example capx and fill with my data (i have even download "Sublime Text 2"). Anyway tnx again!
ImageImageImage
B
42
S
17
G
3
Posts: 155
Reputation: 5,096

Post » Fri Jan 09, 2015 4:01 pm

Your JSON string has [TAB] characters in it:
Code: Select all
"{
""c2array"":true,
""size"":[3,7,1],
""data"":[
[[0],[0],[0], [0],[0],[0],[0]],
[[1],[-1],[-1],[-1],[-1],[14],[26]],
[[2],[30],[10],[8],[-1],[-1],[-1]],
[[3],[0],[-1],[-1],[-1],[-1],[-1]]
]
}"



I guess you copy/pasted it from another editor. If you remove the tabs (replace them with spaces) it works.


Thanks this work perfect,

but why is c2 still saving it in wrong format (or I'm missing something)? I made a level editor in version 192 and it save still like this:

{"c2array":true,"size":[30,8,4],"data":[[[7,20,31,42],[8,21,33,0],[11,0,32,40],[7,0,0,0],[7,21,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]],[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]],[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]],[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]],[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]],[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]],[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]],[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]],[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]],[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]],[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]],[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]],[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]],[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]],[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]],[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]],[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]],[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]],[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]],[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]],[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]],[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]],[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]],[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]],[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]],[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]],[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]],[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]],[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]],[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]]]}

and can't load it in a normal way in to a array or am I missing something?

I like to put the level data in c2 project files (like music etc.) so it get compiled with the code.

Struggling for days with this now and hope that some one can help me with this.
B
46
S
9
G
5
Posts: 110
Reputation: 3,782

Next

Return to How do I....?

Who is online

Users browsing this forum: Google [Bot], newt and 10 guests