Can I save a JSON file?

Get help using Construct 2

Post » Tue Apr 15, 2014 8:07 pm

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?
B
40
S
11
G
4
Posts: 665
Reputation: 8,453

Post » Thu Apr 17, 2014 5:50 am

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/...)' .
You do not have the required permissions to view the files attached to this post.
B
9
S
2
G
1
Posts: 41
Reputation: 708

Post » Thu Apr 17, 2014 7:05 pm

509Dave16 wrote: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! :D
That's all I need I'm good to go. YAY!
B
40
S
11
G
4
Posts: 665
Reputation: 8,453

Post » Thu Apr 17, 2014 7:31 pm

@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.
B
9
S
2
G
1
Posts: 41
Reputation: 708

Post » Tue Apr 22, 2014 4:17 am

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.
B
9
S
2
G
1
Posts: 41
Reputation: 708

Post » Tue Apr 22, 2014 4:52 am

Use node-webkit action to write file.
My professional Royalty Free Music at Scirra Assets Store
--------------------------------
Specs: i5 2500, 16gb of ram, gtx 770, win 7, Focusrite Scarlett 8i6, Mackie mr8mk2, Alesis 320, browsing the net on chrome.
B
91
S
30
G
22
Posts: 1,985
Reputation: 20,149

Post » Tue Apr 22, 2014 8:55 pm

Aye? Node-webkit plugin or something?
B
40
S
11
G
4
Posts: 665
Reputation: 8,453


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 47 guests