You just create an object, and set it as a global variable. It should be the same as uploading a string or a number.
Here's an example of how you see the uploaded objects (I put a mosaic on one of the names for privacy issues). I nested several objects, each one of them represents a robot, with an update frequency that depends on the task they're doing in that moment.
Idle robots will update every 5 seconds, charging robots every 10 or so, navigating robots update more often, and docking robots even faster, to check for the sensors. If I had to join messages, it would mean updating all of them at the same frequency, or having a complicated join setup. As it is now, each robot updates and writes its sensors' data and status in its part of the object.
At any given moment, I can read the whole object and put it on a message, so I get the current status on each robot at the same time.
In this JSON objects tutorial there's a part about nested objects. It's really easy to follow, with examples.
You just have to create the object in one of your function nodes, then store the whole thing in global context as it's explained in the documentation about working with context.
Wow, I can't believe w3schools has a page labelled "JSON objects"
For anyone else reading...
"JSON object" is a misnomer. JSON stands for "JavaScript Object Notation". Essentially, JSON is a string representation of a JavaScript object
You beat me to it. I was in the process of typing a similar message. The error on the page is ironic because in the intro to that section it clearly describes the difference, and then goes on to conflate the two in the page linked here.
Point taken. However, and regardless of the naming inaccuracy in the title, their tutorials are understandable and easy to follow.
I think that, like most of their content, is oriented at people who enter their site without having a clue, and therefore will forgive a mistake like that. I've followed their tutorials for years, and they're one of the first places I search for any HTML/CSS/JS-related issues.
There is a Report Error button at the bottom of the page, which pops up the message
"If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail: help@w3schools.com"
I suggest anyone interested here does that.
Seems like they fixed it already. They changed the name of the section to "JSON Object Literals", and added a note:
It is a common mistake to call JSON object literals "JSON objects" because their syntax is (almost) identical to JavaScript objects.
JSON is based on JavaScript object literals. A JavaScript object literal does not need quotes around the property names, and JavaScript can use single quotes, but JSON cannot.
JSON is a "data-interchange-format". The data is actually only JSON when it is in a string format. When it is converted to a JavaScript variable, it becomes a JavaScript object.