How do I JSON for construct 2

0 favourites
  • 7 posts
From the Asset Store
Casino? money? who knows? but the target is the same!
  • When construct 2 generates json file it is sligthtly different than the one that is being generated using php from mysql data:

    {
       ""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]],
       ]
    }[/code:16of4qpq]
    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:16of4qpq]{"uemail":"mail","upassword":"password","data":"","level":"1000","nickname":"Rager"}[/code:16of4qpq]
    
    How I can load this type of information, from what I've read, construct 2 only understands the way it generates.
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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.

  • 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.

  • 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.

  • 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:

  • 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.

  • 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!

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