logo elektroda
logo elektroda
X
logo elektroda

[Solved] Extracting ValidityData values from an object in Node Red for writing to MySQL

avatar 867 2
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 18962877
    avatar
    Level 36  
    Hello,
    I am asking for help because with the knowledge of java at me -1.
    Using Join generates the following msg.payload (Object)
    Code: Java
    Log in, to see the code
    .

    How can I simply extract a part of e.g. ValidityData? ( I want to write this data to MySQL so I don't even know if I need to assign it to a variable ) ot extract one part podo write it during INSERT to a mysql table.

    Thank you in advance for your help!
  • ADVERTISEMENT
  • #2 18964041
    janek_wro
    Level 29  
    avatar wrote:
    .
    Code: JSON
    Log in, to see the code
    .

    .
    exactly what you have shown is a JSON format.

    Since you are asking about java, I understand that you are receiving this msg and interpreting it in a java program.
    If it is an Object then look at what class.... I'm betting on JSONObject
    then the method
    get(String key) – gets the object associated with the supplied key, throws JSONException if the key is not found

    Unless I have misunderstood your problem....
  • #3 18964438
    avatar
    Level 36  
    Hi,
    My problem has been solved - just extract the relevant part from the payload (something I wasn't aware could be done) - no need to rewrite it to a variable ( in my case
    i.e. msg.payload.ok for the ok part
ADVERTISEMENT