How do I JSON for construct 2

Get help using Construct 2

Post » Sun May 29, 2016 5:49 pm

When construct 2 generates json file it is sligthtly different than the one that is being generated using php from mysql data:
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]],
   ]
}

The above is example of json that construct tend to generate.

Here is a json string that is being generated by my php file on the basis of mysql data:
Code: Select all
{"uemail":"mail","upassword":"password","data":"","level":"1000","nickname":"Rager"}


How I can load this type of information, from what I've read, construct 2 only understands the way it generates.
B
11
S
3
Posts: 44
Reputation: 713

Post » Sun May 29, 2016 9:09 pm

There's a third party plugin that could help you, or you can use some javascript with the browser plugin or your own to parse it.
B
91
S
31
G
102
Posts: 5,232
Reputation: 67,250

Post » Mon May 30, 2016 6:11 am

R0J0hound wrote:There's a third party plugin that could help you, or you can use some javascript with the browser plugin or your own to parse it.

I've tried the Json-to-C2-Array plug in but it throws errors from the start. I'll look into the parsing. That's bizarre that there is no simple way of doing it.
B
11
S
3
Posts: 44
Reputation: 713

Post » Mon May 30, 2016 7:19 am

I was refering to the one made by yann, which doesn't utilize the array object. Also you could also look at the json format that the dictionary object uses. You should be able to more easily adapt that text to be able to load into that.
B
91
S
31
G
102
Posts: 5,232
Reputation: 67,250

Post » Tue May 31, 2016 3:31 pm

I have a Java library that turns C2 'array' JSON into Java arrays. You have to parse the text and manually juggle stuff. I'll be happy to send you my Java source for this particular library if you want. You will have to translate it to PHP though.

This guy seems to have a start on something that parses it for PHP: parsing-custom-json-with-custom-php_t93732
https://www.ravenheart.ca/home
Company name changed to avoid Facebook-type shenanigans

"Someone once told me I bite off more than I can chew...

I told them I would rather choke on greatness than nibble on mediocrity."
B
22
S
6
G
1
Posts: 1,414
Reputation: 4,822

Post » Fri Jun 03, 2016 10:06 pm

Thanks but I've kind of gave up on this idea for now, as i'm a beginner in php so i've decided to store my whole json in one column.
B
11
S
3
Posts: 44
Reputation: 713

Post » Mon Jun 06, 2016 12:39 pm

StanBond wrote:Thanks but I've kind of gave up on this idea for now, as i'm a beginner in php so i've decided to store my whole json in one column.

Simple and stupid is always good!
https://www.ravenheart.ca/home
Company name changed to avoid Facebook-type shenanigans

"Someone once told me I bite off more than I can chew...

I told them I would rather choke on greatness than nibble on mediocrity."
B
22
S
6
G
1
Posts: 1,414
Reputation: 4,822


Return to How do I....?

Who is online

Users browsing this forum: Lancifer, Yahoo [Bot] and 4 guests