I've modified the example of saveJSON() on the p5.js website to save outside setup().
Running the code in the editor outputs a weird string instead of valid JSON.
var json;
function setup() {
json = {}; // new JSON Object
json.id = 0;
json.species = 'Panthera leo';
json.name = 'Lion';
}
function draw() {
}
function mousePressed() {
saveJSON(json, 'lion.json');
}
Content of lion.json when running the code in the editor:
�w^~)�
Content of lion.json when running the code in the browser:
I've modified the example of
saveJSON()
on the p5.js website to save outsidesetup()
. Running the code in the editor outputs a weird string instead of valid JSON.Content of
lion.json
when running the code in the editor:Content of
lion.json
when running the code in the browser: