Help parsing a json file (Urgent)

Hi,
I am a beginner with node red. I am receiving from The Thing Stack quite a complex JSON string over MQTT. I am only interested in a very small subset of the JSON payload received.
What is the best way to extract the "decode_payload", and all its data (I mean "decoded_payload":{"analog_in_0":4.21,"analog_in_1":5.22,"digital_in_0":1}) in the long JSON below.

Thanks a lot for your help,

I am stuck.

Marc

"{"end_device_ids":{"device_id":"hive-00001","application_ids":{"application_id":"hive-app-id"},"dev_eui":"AA00AA00BB00BBAA","join_eui":"AAAAAAAAAAAAAAAA","dev_addr":"260B1E5D"},"correlation_ids":["as:up:01F3YW7W7CRWHNW5TK1F6AZGE6","gs:conn:01F3Y16MFA0TCEEY8RMAEHSQPY","gs:up:host:01F3Y16MFNJ5G7VB6HN094BBKZ","gs:uplink:01F3YW7W0VPE0YXKJAEA8D38NK","ns:uplink:01F3YW7W0XSY3NX3EKQZBK0EYK","rpc:/ttn.lorawan.v3.GsNs/HandleUplink:01F3YW7W0XJRY37ZGT3X9PJMQJ","rpc:/ttn.lorawan.v3.NsAs/HandleUplink:01F3YW7W7CX3STQB4HHWZPH8Y7"],"received_at":"2021-04-23T08:06:20.141290010Z","uplink_message":{"session_key_id":"AXj7II2SgHRA1OoyoTuAEg==","f_port":1,"f_cnt":1291,"frm_payload":"AAABAAIBpQECAgo=","decoded_payload":{"analog_in_0":4.21,"analog_in_1":5.22,"digital_in_0":1},"rx_metadata":[{"gateway_ids":{"gateway_id":"venon-mch-gn"},"time":"2021-04-23T08:06:19Z","timestamp":3454645003,"rssi":-33,"channel_rssi":-33,"snr":8.75,"uplink_token":"ChAKDgoMdmVub24tbWNoLWduEIvmpu8MGgwI+/+JhAYQj72kvAMg+MWNx8XSBg=="}],..."

Hi Marc, as a newbe to node-red i will list out some resources. No more than an hour or so reading / watching & you should be flying...

Firstly,

This post should help to clarify the difference between Javascript objects and JSON.

Secondly,

There’s a great page in the docs that will explain how to use the debug panel to find the right path to any data item.

Pay particular attention to the part about the buttons that appear under your mouse pointer when you over hover a debug message property in the sidebar.

BX00Cy7yHi

https://nodered.org/docs/user-guide/messages

And last but not least

I recommend watching this playlist: Node-RED Essentials. The videos are done by the developers of node-red. They're nice & short and to the point. You will understand a whole lot more in about 1 hour. A small investment for a lot of gain.


Quick version...

A JSON string can be converted to an object where you can use the buttons in the debug window (as demos in the GIF above)

Often (like in the MQTT) node, you can set the MQTT node settings to parse the JSON into an object (meaning you dont need the JSON node).


Hope that helps.

And one more which describes how, for the future, to post flows or code so that the forum does not mess up the format: How to share code or flow json

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