Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Extract data from long Json message
#1
Hi,

I am sorry to bother with this question as i have seen it was asked before, but after watching the video you posted on how to extract the data, i still can not mange to extract what i need.
The Json payload i receive is :

{"state":{"reported":{"M..1:2-1":"00","AM..4:10-1":"04bc","V..4:8-1":"0021","M..1:10-1":"00","M..1:11-1":"00","V..6:4-1":"0000012c","V..4:12-1":"0000","V..4:24-1":"0010","V..4:28-1":"0465","V..4:36-1":"0000","M..1:6-1":"00","M..1:4-1":"00","M..1:5-1":"00","M..1:12-1":"00","V..2:990-6":"1d2404122205"}}}

There are a lot of variables Smile but i would like to extract for example "AM..4:10-1":"04bc", 04bc is the value which is in hex, i would also like to convert to decimal. i would like to display only the value 04bc in decimal (1212).

I have tried also with JavaScript script, but it did not work Sad

Please can you help me with this. Thanks in advance
Reply
#2
Hi,
1. Store the json message to a Variable. Add a value display to see your Json
2. Add the script "Json to Variable converter":
Select as input the ariable with the text.
Select as output the variable Emulator V0
Value json path: state/reported/AM..4:10-1 
Add a value display for this variable. You have to see the hex number: 04bc
3. Add the script "Hex Converter":
Select as input the variable Emulator V0
Select as output the variable Emulator V1
Type: Hex to INT
Hex Format: 12ef
Add a value display for the Variable emulator V1.
You will see the value: 04bc
Reply
#3
Thumbs Up 
(04-13-2024, 06:55 PM)iliaslamprou Wrote: Hi,
1. Store the json message to a Variable. Add a value display to see your Json
2. Add the script "Json to Variable converter":
Select as input the ariable with the text.
Select as output the variable Emulator V0
Value json path: state/reported/AM..4:10-1 
Add a value display for this variable. You have to see the hex number: 04bc
3. Add the script "Hex Converter":
Select as input the variable Emulator V0
Select as output the variable Emulator V1
Type: Hex to INT
Hex Format: 12ef
Add a value display for the Variable emulator V1.
You will see the value: 04bc

Hi Ilias,

thanks a lot, "Value json path: state/reported/...." this part is what i needed. All works fine now. Thank a lot for the quick reply.  Have a nice weekend, and again greatly appreciate your reply.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)