How do I format JSON in a way Construct 2 understands?

0 favourites
  • 5 posts
From the Asset Store
Casino? money? who knows? but the target is the same!
  • Hello everyone,

    it's been a long time since I've been back here but glad to be back at the same time. I've recently been playing around with Construct 2 in the hope of creating a very simple RPG mechanic. But, I hit a roadblock when I found that I couldn't seem to get C2 to respond to the JSON format that I was passing .

    For example the following just wasn't getting me anywhere (as an array of objects):

    [{
    	"id": "1",
    	"string": "This is a string that belongs to the id of 1."
    }, {
    	"id": "2",
    	"string": "This is another string that belongs to the id of 2."
    }][/code:1ixvpplt]After some searching I found a couple of examples, so I could probably work with those. But I have a couple of questions, one being, why does Construct require a special format when it comes to JSON exactly? Or, is it the simple case that I'm just not doing it right by loading as Ajax and parsing it in to an array or dictionary?
    
    And secondly, is there some form of reference in the manual that I've overlooked that goes in to detail about it?
    
    My apologies if I've overlooked the obvious, but I'm not having too much luck and wondered if anyone else had a similar issue.
    
    Thanks!
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The easiest way to figure out C2's format is to mock up a few elements, and look at the JSON text. Once you see the pattern, then you can build your own data format and it will work.

  • Ah that's a good idea actually. Thank you! I take it construct has its own special format due to the fact it needs to work on many different devices? Or is it just simply the way it's written?

  • The format wasn't meant to be modified by hand. It's just an easy way to save the data by string and load it back again. It also always has to save a 3D array, so it gets complicated formatting three dimensions of data.

  • Ah I see what you mean. Thanks very much for clarifying!

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