I am listening to a device with TCP request node and I get the information in string as shown in the attachment(1). how to convert it to json object?
And I get an error converting to json object using json node as shown in attachment(2)
The JSON node converts a JSON string to an Javascript object, or reverse. Your string from the TCP node is a string not a JSON string.
What is the sending device? Perhaps its format is documented / some obscure protocol format?
Can the device be configured (or updated) to send valid JSON or some other well formed/structured data (XML/YAML/CSV etc)?
If not, then manual parsing in a function node will be possible
understood thanks.
The device is a sick inspector camera. There are some options to configure output, however I dont see any option to set output format to json object.
I will try those. Thanks.
To me - that looks as if you can create any format you wish in the format string editor box?
and just use the place holders where you want the data?
Example to submit it as a JSON string:
{"image_number":<IMAGE_NUMBER/>,"found_blobs":<FOUND_BLOBS/>}
Super. It works, also started getting messages in node red as json object.
As FOUND_BLOBS (and POSITION_(X,Y) ) look more like a string you may need more quotes around it eg >,"found_blobs":"<FOUND_BLOBS/>"}
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.