Complex Arrays and JSON

Get help using Construct 2

Post » Wed Jun 05, 2013 9:52 pm

Hi everybody. I'm pretty new to Construct 2, but even newer to JSON.

I'm in them midst of building a quiz-type of game that needs to be fed content from an external .json file. I know how I would do this in xml, but I feel my solution for using json might be a bit I was wondering if I could get some feedback.

In XML, I could structure something like this:

          <questionPrompt>Question 1</questionPrompt>
          <answer>Choice A</answer>
          <answer>Choice B</answer>
          <questionPrompt>Question 2</questionPrompt>
          <answer>Choice A</answer>
          <answer>Choice B</answer>
          <answer>Choice C</answer>

I would then iterate through it, and set up an array like: [[Question 1][Choice A, Choice B, Choice C]]

But in json, I don't seem to have the ability to layer my arrays. So my feeble newbie attempt is something like this:
"data":[[["Question 1"],["Choice A|Choice B"]],
[["Question 2"],["Choice A|Choice B|Choice C"]]]

Then I'd use tokenat to parse through the "Choice A|Choice B" strings...

So...sorry about the length, but does this seem like a legitimate way to store layered data like this? Or am I going about it in a super clunky manner? Anyway, I appreciate feedback! Thanks.
Posts: 10
Reputation: 822

Return to How do I....?

Who is online

Users browsing this forum: beguinner, Metathronos, R0J0hound and 60 guests