I’m attempting to save some data but i’m getting the following error:
XML Parsing Error: syntax error
Location: file:///path/JS/Domino/data/test.json
Line Number 1, Column 1:
(there’s nothing after de colon)
I tried to debug this in the firefox console the following way (the variable’s name is pieces)
saveJSON(pieces, ‘save.json’) // correctly prompts save and creates file
// opening the file on firefox reveals that the file was saved as a proper JSON object
loadJSON(‘save.json’) // error happens
I verified that the path is correct and tried saving a JSON.stringify object and using loadStrings but got the same result.
just for understanding,
you run p5.js
from https://editor.p5js.org/ ?
in what browser?
on a win ?10? computer,
and you want load a file what is on that computer?
i hope that is not possible!
you should upload the file like to /data/ or /assets/ for your online account,
or use something like DROP ( a window what expects you upload (drag/drop) a file interactively )
I run an offline project and open the html file in firefox and usually I have no problem.
I am using a 2015 MBP.
I’m saving and loading the data locally.
also the saving by js. to HD is not possible,
what you do is you download it interactively
( means you save it manually to HD, and also you can upload it manually … )
but never should JS read and write automatically from/to your drive
Saving is indeed manual. I have however, seen occasions where the loading of JSON objects is done manually, as long as it is done within the folder where the project is saved. (this example from the coding train: https://www.youtube.com/watch?v=U9wiMM3BqLU&t=687s)
Just numbers… from what i can tell saveJSON() works as it is supposed to (otherwise maybe firefox would not be able to load the project) and it’s loadJSON() the one not working properly