We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi there,
do you know, how to generate a JSONArray with p5? According to the p5 reference, there must be a way to save a .json file containing several JSONobjects with saveJSON, but there is no example for the syntax of that JSONArray (only for JSON-Objects).
I really appreciate any help!
Answers
Hello
Check this
https://p5js.org/examples/arrays-array.html
http://stackoverflow.com/questions/30818935/extracting-info-from-a-json-p5-js
https://p5js.org/examples/arrays-array-objects.html
"sketch.js":
"lion.arr.json":
"lion.obj.json":
Hey hey, so that helped me a little - thanks so far!
I have these three arrays, that are getting filled during a song is playing:
My frameRate is equal to 3, so that every second three new values are pushed in the arrays.
After the song, the JSON file is generated (at least that is the plan) by pushing a "over-button" I built before:
And now I don't know how to write, that every single JSON object should contain these three values.
Do I need a for-loop before I generate the JSON file with i < idArray.length?
Yeah, I fixed it with:
Indeed, if your 3 arrays are interconnected by the same index, why not encapsulate them as 1 object from the get go, and use 1 array only for those unified objects? :\">
I was actually finishing that same plan. And now it's ready. You can check it online below too: B-)
http://CodePen.io/GoSubRoutine/pen/RoENJd/right/?editors=1011
"index.html":
"sketch.js":
P.S.: As you can see, it's relying on 3 random values to fill up those 3 properties each time a mouse is pressed at the canvas. :ar!
Wow, haha, for me that looks crazy! :D
But I guess (after some weeks living in the java script world) I understand your code! Great! Thanks for that version ;)