Search code examples
javascriptjsonprocessing.js

Processing.js a way to create JSON


Is there some kind of constructor or some way to create Json object in processing.js? I know that in the Processing library have JSONObject but in the processing.js there is nothing like that everything that I found for processing.js is how to load JSON but I need some kind of way to create it. If there is way can someone show me how to do it.


Solution

  • JSONObject is used by Java (or Processing in Java mode) to create JSON Strings that can be used by JavaScript.

    Processing.js is already JavaScript, so you don't need to go through all that trouble.

    If you have an object in JavaScript (and Processing.js is already JavaScript), then you can just use the JSON.stringify() function that's built in to JavaScript (and Processing.js).

    But again, you might not even need to do this. Processing.js is already JavaScript, so you can probably just use the objects directly in JavaScript code without converting them to JSON first.