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=map

    Get 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.

    0_1609603120284_UIFlow_JSON_Decode.png
    Many thanks for the advice.
    Regards
    Phil