Can I save a JSON file?

0 favourites
  • 8 posts
From the Asset Store
Source File, music and art pack for Android Negotiator
  • I am currently writing a 3D game in JS with a Text Editor.

    But I would like to use Construct 2 to quickly prototype a level editor for my project.

    It would greatly simplify things if I could just download a JSON via a "save" button.

    Is this possible?

    Or is there a third party plugin that can do this?

  • Hey, ! I'm kind of a noob when it comes to Construct 2, though I've been trying to discover some form of a "save" functionality that you just described for saving JSON. As it stands there is this tutorial(manual entry) called 'Using project files in Construct 2' on scirra.com. If you search for the 'Making level editors' section in the manual entry, it will describe some plugins you could use to save data, which are the Array and Dictionary Plugins. Both the Array and Dictionary Plugins have DownloadJson and LoadJson Actions which can be used to store the data in a file and load the data from a JSON string. You'll also need the AJAX plugin to request the JSON file. Below I'm providing an attached .capx demo project of saving/loading the JSON. I'm using Project files though so I had to import the test_json.json file that contains the saved JSON format of the Array Plugin Object that I used in the demo project to store a JSON string of the example_json.json file. It automatically asks you to save a file test_json.json upon running the project. And you can click the 'LOAD JSON' button to load the JSON format of the Array Plugin which was orginally saved and then imported into the project unfortunately. If you used the Request GET or Request POST Actions to call scripts to return/save the JSON instead of the RequestFile Action on the Ajax Plugin, you could bypass the need to import files and use the Array Plugin. And if you're interested search for this work in progress Plugin for parsing/forming JSON strings: '[plugin] JSON (import/export/generate/edit/inspect/...)' .

  • Hey, ! I'm kind of a noob when it comes to Construct 2, though I've been trying to discover some form of a "save" functionality that you just described for saving JSON. As it stands there is this tutorial(manual entry) called 'Using project files in Construct 2' on scirra.com. If you search for the 'Making level editors' section in the manual entry, it will describe some plugins you could use to save data, which are the Array and Dictionary Plugins. Both the Array and Dictionary Plugins have DownloadJson and LoadJson Actions which can be used to store the data in a file and load the data from a JSON string. You'll also need the AJAX plugin to request the JSON file. Below I'm providing an attached .capx demo project of saving/loading the JSON. I'm using Project files though so I had to import the test_json.json file that contains the saved JSON format of the Array Plugin Object that I used in the demo project to store a JSON string of the example_json.json file. It automatically asks you to save a file test_json.json upon running the project. And you can click the 'LOAD JSON' button to load the JSON format of the Array Plugin which was orginally saved and then imported into the project unfortunately. If you used the Request GET or Request POST Actions to call scripts to return/save the JSON instead of the RequestFile Action on the Ajax Plugin, you could bypass the need to import files and use the Array Plugin. And if you're interested search for this work in progress Plugin for parsing/forming JSON strings: '[plugin] JSON (import/export/generate/edit/inspect/...)' .

    Thank you so much man!

    That's all I need I'm good to go. YAY!

  • , you are welcome. The way I did the Saving and Loading of the JSON files was an attempt to strictly use Construct 2 Actions, which isn't the best because of some limitations. If there was a way to have a file imported into the Construct 2 project at Runtime using some kind of a System Action, then you wouldn't have to manually import JSON files into the project.

  • By the , there is a tutorial called 'Ajax Example with Construct 2' which covers how to load a file from dropbox or a server that has some contents like text or json. It will be much better to use the Ajax.RequestGet or Ajax.RequestPost since you won't have to import files into your Construct2 project.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Use node-webkit action to write file.

  • Aye? Node-webkit plugin or something?

  • have you still got a copy of the capx

    thanks

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