Extracting my content value from a msg.payload?

Am using https request to populate the msg.payload using split node but i want to push the data to MYSQL database before the i am having the error ref screenshot to separate my payload json string to difference outputs

please suggest me

thanks

Where does that data come from? Have you done something to it to make it like that?

Show us your flow and debug values as the msg passes through the each of nodes

Hi Steve ,

I use HTTP IN node to receive the data using Post method and data json format is convert to Json Object which Json node and i split the msg.payload to get the payload data

image

Use the copy value button
chrome_aYxpv0MoA9

Paste reply as code block (to prevent format formatting messing up the data)
```
paste copied value between backticks
```

{"{\"Source\":{\"ReportTime\":\"2022-03-22T11:10:05Z\",\"GroupID\":\"Group 01\",\"DeviceID\":\"SC8131 (0002d18b372f)\",\"ModelName\":\"SC8131\",\"MacAddress\":\"00:02:D1:8B:37:2F\",\"IPAddress\":\"192.168.1.46\",\"TimeZone\":\" 5\",\"DST\":\"0\"},\"Data\":[{\"RuleType\":\"Counting\",\"CountingInfo\":":{"{\"RuleName\":\"Rule\",\"In\":1,\"Out\":1,\"StartTime\":\"2022-03-22T16:39:00 0530\",\"EndTime\":\"2022-03-22T16:40:00 0530\"}":[""]}}

I want to Collect the RuleName, IN ,OUT, STARTTIME,ENDTIME DATA AND publish to MYSQL DATA BASE

Kindly suggest if my Function is not proper

That looks wrong. A JSON node should convert to or from JSON < > object. Your 2 debug nodes both show payload as an object.

  1. Can you remove the link between the HTTP-In and the JSON node - THEN - capture the output again

  2. What system calls your endpoint /users ? I suspect the JSON is malformed (but still valid).


  1. Attached the output again removing the HTTP-IN and JSON node
  2. Yea endpoints that referees as /Users.

@dheeju1314 ....

I wanted you to DELETE the link between the HTTP-In and the JSON node and COPY the PAYLOAD

(7)
chrome_aYxpv0MoA9

(8)
Paste reply as code block (to prevent format formatting messing up the data)

`paste copied value between backticks`




Sorry, I dont understand your reply - it did not translate well.

I will try to re-word my question...
2. Which other application calls the node-red endpoint http://x.x.x.x/users? I suspect the BODY sent in the POST is malformed JSON (but still valid).



1.This is the Source am sending data to HTTP IN request
image
2.using this http IN - post node am able to get data at ?users.

3. connect debug to HTTP-IN node Output in screenshot
4. payload:-

{"{\"Source\":{\"ReportTime\":\"2022-03-22T11:58:05Z\",\"GroupID\":\"Group 01\",\"DeviceID\":\"SC8131 (0002d18b372f)\",\"ModelName\":\"SC8131\",\"MacAddress\":\"00:02:D1:8B:37:2F\",\"IPAddress\":\"192.168.1.46\",\"TimeZone\":\" 5\",\"DST\":\"0\"},\"Data\":[{\"RuleType\":\"Counting\",\"CountingInfo\":":{"{\"RuleName\":\"Rule\",\"In\":2,\"Out\":1,\"StartTime\":\"2022-03-22T17:27:00 0530\",\"EndTime\":\"2022-03-22T17:28:00 0530\"}":[""]}}


I have go the String value for the reference

Yes, I know how to convert it - its just trying to help you do the RIGHT thing.

I know how to solve it - but it would be a HACK due to malformed JSON coming in.

POST data - is badly formed JSON...

{
    "{\"Source\":{\"ReportTime\":\"2022-03-22T11:58:05Z\",\"GroupID\":\"Group 01\",\"DeviceID\":\"SC8131 (0002d18b372f)\",\"ModelName\":\"SC8131\",\"MacAddress\":\"00:02:D1:8B:37:2F\",\"IPAddress\":\"192.168.1.46\",\"TimeZone\":\" 5\",\"DST\":\"0\"},\"Data\":[{\"RuleType\":\"Counting\",\"CountingInfo\":": {
        "{\"RuleName\":\"Rule\",\"In\":2,\"Out\":1,\"StartTime\":\"2022-03-22T17:27:00 0530\",\"EndTime\":\"2022-03-22T17:28:00 0530\"}": [
            ""
        ]
    }
}

I am trying to find the correct solution for you.

What send options does your application have?

image



Thanks

please find the refer protocols that can be integrate

Could you try the XML setting & see what arrives in msg.payload?

Again, capture the debug payload as a string (using the "Copy Value" button) and paste it into a reply. in a ``` code block ```

{"<Message><Source><UtcTime>2022-03-22T15:30:05Z</UtcTime><GroupID>Group 01</GroupID><DeviceID>SC8131 (0002d18b372f)</DeviceID><ModelName>SC8131</ModelName><MacAddress>00:02:D1:8B:37:2F</MacAddress><IPAddress>192.168.1.46</IPAddress><TimeZone> 5</TimeZone><DST>0</DST></Source><Data RuleType":"\"Counting\"></Data><Data RuleType=\"ZoneDetection\"></Data></Message>"}

i was configured the option into xml and debug msg comes like this

for the above reference screenshot data is not coming because not one is there at sensor so msg.payload will be coming like this

i have kept this as general but when XML node connected am getting the error as invalid character in name

@Steve-Mcl discussion happend regarding previous screenshots, Looks like am unable to get the proper output still. can you kindly help. what functions need to add to get the proper output for IN and OUT counts

payload.In["{\"Source":{"ReportTime":"2022-05-16T11:53:05Z","GroupID":"Group 01","DeviceID":"SC8131 (0002d18b372f)","ModelName":"SC8131","MacAddress":"00:02:D1:8B:37:2F","IPAddress":"192.168.1.50","TimeZone":" 8","DST":"0"},"Data":[{"RuleType":"Counting","CountingInfo":"]["{\"RuleName":"Rule","In":1,"Out":1,"StartTime":"2022-05-16T19:52:00 0800","EndTime":"2022-05-16T19:53:00 0800"}"]

Impossible to say without seeing original data and what is happening inside your function...

image