Logic Machine Forum
JSON pdecode failes => solved - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: JSON pdecode failes => solved (/showthread.php?tid=5459)



JSON pdecode failes => solved - cgn - 10.06.2024

I get the following data from a HTTP get request:

Code:
* table:
["inverters"]
  * table:
   [1]
    * table:
     ["serial"]
      * string: 000000000000
     ["AC"]
      * table:
       ["0"]
        * table:
         ["Power"]
          * table:
           ["d"]
            * number: 1
           ["v"]
            * number: 627.7999924
           ["u"]
            * string: W

I want to use pdecode to write the values in some group adresses. 


Code:
oDTUResponse = socket.http.request(url)

data3 = json.pdecode(oDTUResponse).inverters[1].serial
log(data3)

data4 = json.pdecode(oDTUResponse).inverters[1].AC["0"].Power.v
log(data4)

Edit: "" were missing in the code.