How do I load a JSON file that originated from the Download JSON command into a new array?

0 favourites
  • 4 posts
From the Asset Store
In this game you will command the character by voice command.
  • Hi everyone, this is my first time on the forums here so I am terribly sorry if I have made any mistakes in creating this thread, I still haven't got the hang of it.

    So, I have an Array the contents of which I have saved as a JSON file (which I named "E001.json") through the Download JSON command of the Array.

    So now I have this file saved in my computer and have imported it into the project files for future reference. So far so good. I have set the Array to get cleared on the start of the layout. After that, when I do a certain action (for now that action is clicking a button - for testing purposes), I want the Array to load said E001.json . I use the AJAX command to fetch the JSON project file and then load it into the Array. Well, I get no errors but nothing happens. The array stays as it was, full of 0s. I have made no modifications to the JSON file, but this probably is a mistake on my part. Why, you ask? Well, when I tried loading a JSON string into the Array directly (not load the file but its contents instead), the very same string that was produced by Construct2 in the first place displays errors everywhere, saying that a lot of characters such as "{" are not recognized and shouldn't be there. But this is the string created by the program! I don't get it. What am I doing wrong? Any help would be appreciated!

    Thanks in advance!

  • "I use the AJAX command to fetch the JSON project file and then load it into the Array."

    What are the events you used to do that?

    It should be AJAX request json with a tag, then on tag completed set value in the array to ajax.lastdata

    The fact that it is still a bunch of 0s means nothing was successfully added to the array.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Yes, exactly that is the problem. As far as the AJAX command is concerned, I used "Request File" to get the file and then referenced it with "AJAX.LastData". I also tried the latter with "AJAX.Tag"

  • Please post a link to the capx, or some screenshots of the events.

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