We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I need to read (and write in the future) a list of names and infos that will congregate into many array of objects, and to make it easyer to store and organize this infos I would like to save it to a JSON file;The problem is that using P5.js, every attempt to read such files results in a "Array[ ]" response from the browser consolle. I tryed to debug the example page at p5.js reference and it gives the same result, an empty array. Trying to load a local file gives this errors: "syntax error file.json:1:1" "not well formatted file.json:1:1" and printing it gives an empty array. This files should be well written as I copyed them from online examples unless thwy all where missing some part of the file(something that's well possible as I don't know the structure of the file, while knowing the object properties". Also, saving the same files as a variable inside the sketch gives no problem, but in fact I need it as external file.
EDIT: I have the same problem with loadStrings, and I only tryed in locale with firefox developer ed
Answers
I've added these 2 lines below at the end of draw() from http://p5js.org/reference/#/p5/loadJSON:
And I couldn't see anything wrong! (:|
When asking folks to troubleshoot, it should be accompanied by running excerpts of the problem! :-w
Duh, while uploading it to my server to show it to you, it ended up working.......... #-o (#tattical facepalm).
yet when running in local, the program works,loads and reads properly the file, but there is a consistent "syntax error plugList.json:1:1" in the console, that isn't there in the version uploaded online;
and data is retrieved as
Works with no problem online but gives warnings on locale; Any reason?
sketch ; source and the file is above
@ondsinet_: This is a FAQ. check for warnings about loading local files. Many browsers block this since it's a security risk...
Made the shorter version below: $-)
Executed the "index.html"
file:///
above locally w/o any server artifice: :ar!anyway anyhow it was partially the println command fault, as it showed an empty array, while console.log gives the expected result
In the beginning both print() & println() were alias for console.log().
But some insanity idea happened there and they had decided to have their own poor implementation.
Ah! It doesn't accept multiple args anymore! 3:-O