Whitespace in Json

Hello,

I am using the REST sensor to read some external IP Json file.
Everything works with:

value_template: '{{ value_json[1].Data }}'

But I have a sintax error with whitespace keys:

value_template: '{{ value_json[1].People Name }}'

I have tryed with underscore but this searches for a key with underscore that obviously does not exist. If I use quotes there is a sintax error as without them.

Any Ideas?

value_template: "{{ value_json[1]['People Name'] }}"

Thank you very much! It works!

Could you please tell me how to replace [1] with the last item of the json file? maybe [value_json.length-1]?

Use -1 for last item, -2 for second to last, etc

1 Like