Send JSON to SVG node

Hi all.
My name is Gianluca and i'm new in this forum.
I hope you can help me with this problem.
I want to send JSON message to SVG node with a function or similar because i want to evaluate an input bool variable.
Now i'm able to send message with INJECT node by selecting Payload to Json in node properties.
This is the message:

{
"camera": {
"colour": "green"
},
"position": {
"y_e1": 30
},
"title": "New banner title by databind"
}

A JSON object is a string. Do you mean that you want to send a Javascript Object to the node?
If so then have a look at the node red docs pages Working with Messages and the one on Writing Functions. If you still have problems then come back and explain what you are having difficulty with.

...also have a look at this video tutorial - https://www.youtube.com/watch?v=24ZY3CEsiow

To send JSON (or to be technically correct, a JS object) from a function to the SVG node, you simply do the following...

msg.payload = {
  property : "value",
  a_value : 42
}

// Add more properties...
msg.payload.a_new_property = 77;

return msg;

It would be worth your time reading up on JS objects and the node-red documentation on "working with messages"

Thanks Paul, i've just resolved.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.