Good morning,
I would like to know if there is a specific function in javascript, which extracts from the message below only the value "141", after identifying the term "Temperatura.SaidaATM".
{ "d" : { "Temperature.ATM Output" : [141]
**Edit: The above package comes from sub MQTT in Json format.
The complete package is this below:
{"d":{"Temperature.ATM Output":[141]},"ts":"2021-12-18T13:28:34.964579"}
However I need to treat it to extract only the information between brackets "[xxx]", in the example above it is "141" but this value varies.
But I also need the quoted reference "Temperature.OutputATM".
Summing up: 1- The message "{"d":{"Temperature.OutputATM":[xxx]}"ts":"2021-12-18T13:28:34.964579"}" is received.
2- I need to extract the xxx from a javascript code
3- When reading "Temperatura.SaidaATM" in the message, return only what is in square brackets right after "[xxx]"
4- Final message return: xxx
Thank you in advance!
Yes. You have an object and you can select by key like that:
data = { "d" : { "Temperature.ATM Output" : [141] }}
console.log(data.d["Temperature.ATM Output"][0])