🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Accessing decoded JSON array

    UIFlow
    5
    6
    10.5k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • P
      PhilG1300
      last edited by PhilG1300

      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.

      1 Reply Last reply Reply Quote 0
      • sodokuS
        sodoku
        last edited by

        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

        P 1 Reply Last reply Reply Quote 0
        • P
          PhilG1300 @sodoku
          last edited by

          @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

          K 1 Reply Last reply Reply Quote 1
          • K
            Kombistack @PhilG1300
            last edited by

            @philg1300
            Thanks Phil, this was very helpfull for me too.

            R 1 Reply Last reply Reply Quote 0
            • R
              rmorgan @Kombistack
              last edited by

              @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

              0_1686859057609_197a7526-c043-4220-8830-205522146090-image.png

              ajb2k3A 1 Reply Last reply Reply Quote 0
              • ajb2k3A
                ajb2k3 @rmorgan
                last edited by

                @rmorgan please dont double post.

                UIFlow, so easy an adult can learn it!
                If I don't know it, be patient!
                I've ether not learned it or am too drunk to remember it!
                Author of the WIP UIFlow Handbook!
                M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post