Mobile companion App & Node Red

Can anyone help me pass the following into msg.payload please. I can’t work out how to do the sub groups. Thanks

title: “Wake up!”
message: “The house is on fire and the cat’s stuck in the dryer!”
data:
ttl: 0
priority: high

Not sure what you want, do you mean something like this?

{“title”: “Wake up!”, “message”: “The house is on fire and the cat’s stuck in the dryer!”, “data”: {“ttl”: 0, “priority”: “high”}}

Yes. Perfect. Thank you so much for your help.

Just so I can read up more about this type of formatting can someone tell me official terminology please.

If I wanted to do the same with this would I just keep on adding curly brackets sub sections?

[quote=“Burningstone, post:2, topic:170693, full:true”]
Not sure what you want, do you mean something like this?

{“title”: “Wake up!”, “message”: “The house is on fire and the cat’s stuck in the dryer!”, “data”: {“ttl”: 0, “priority”: “high”}}

message: “Something happened at home!”
data:
actions:
- action: “alarm” # The key you are sending for the event
title: “Title” # The button title

Sorry I can’t seem to paste this and keep the formatting.

Thank you

This type of formatting is referred to as ‘JSON.’

1 Like

To keep the formatting, highlight the text and press the </> in the top bar.

The formatting is important to know what should be enclosed in curly brackets :slight_smile:
Every dictionary is surrounded by curly brackets. E.g.

message: "test"
title: "test title"

This is a dictionary, with the keys “message” and “title” and the corresponding values “test” and “test title”. In JSON this would become:

{"message": "test", "title":"test title"}

Now a more “complex” case:

message: "test"
title: "test title"
data: 
  action: "test action"
  name: "test name"

This is a dictionary within a dictionary. The first dictionary has the keys “message”, “title” and “data” and the corresponding values are “test”, “test_title” and the value for data is another dictionary, which contains the keys “action” and “name” and the corresponding values “test action” and “test name”. Everything that is indented at the same level belongs to the same dictionary. Remember every dictionary is surrounded by curly brackets in JSON so this becomes:

{"message": "test", "title": "test title", "data": {"action": "test action", "name": "test name"}}

I hope this helps for a basic understanding.

Thank you once again for your help. That was very helpful and I’ve learnt so much, I’m definitely going to continue to read a whole lot more. Cheers.