0 Favourites

Can I save a JSON file?

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

  • Construct 3

    Buy Construct 3

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

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

  • Use node-webkit action to write file.

  • Aye? Node-webkit plugin or something?

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