Accessing decoded JSON array
-
Hello,
I am new to using UIFlow, but not to programming.
I am using UIFlow on my M5Stack project.
I am having difficuly in accessing a JSON decoded array.
Within the Python code I have a snippet of code:-Decoded_Packet = json.loads(Packet) Decoded_Location = Decoded_Packet["location"]
Which works in my application, but it won't change to the UIFlow - Blockly representation, nor save and load correctly.
So my question in Blockly what is the equivalent of:-
Decoded_Location = Decoded_Packet["location"]
or
Decoded_OutTemp = Decoded_Packet["stats]["current"]["outTemp"]Which work in the Python coding.
Regards
Phil. -
You should be able to use the "get key in map" block from "map"
https://docs.m5stack.com/#/en/uiflow/data_structure?id=mapGet key location from map Decoded_Packet
-
@sodoku
Hello,
Yes your answer is correct, I have just found the answer just before you replied!!
See attached screenshot.
Many thanks for the advice.
Regards
Phil -
@philg1300
Thanks Phil, this was very helpfull for me too. -
@kombistack Im trying to do something similar to this. I'm subscribing to an AWS IOT topic which is publishing a JSON. I can receive the whole message but in trying to extract one field from the JSON its not returning anything. Pic below
-
@rmorgan please dont double post.