10513 questions

12523 answers

19449 comments

22057 members

0 votes
201 views 0 comments
by

Hello,

This question is similar to this one but I suppose I'm wording this a little differently.

The "Data to Server" (DtS) function seems to be encoding all the data into the name of a single attribute in the JSON string, with the value being a blank string ("").
For this example, my format string is "{"TS": "%t", "D": "%d", "slave": "%p", "data": "%a"}".

OBSERVED NON-OBJECT (ARRAY) FORMAT
{"{\"TS\": \"1642592890\", \"D\": \"19/01/2022 11:48:10\", \"slave\": \"172.16.0.3\", \"data\":\"25484,0,0,0,0\"}": ""}

OBSERVED OBJECT FORMAT
{"{\"TS\": \"1642592890\", \"D\": \"19/01/2022 11:48:10\", \"slave\": \"172.16.0.3\", \"data\":\"25484,0,0,0,0\"}": ""}

I did expect the data to be formatted as below...

EXPECTED NON-OBJECT (ARRAY) FORMAT

"[{\"TS\": \"1642592870\", \"D\": \"19/01/2022 11:47:50\", \"slave\": \"172.16.0.3\", \"data\": \"0,0,0,0,0\"}]"

EXPECTED OBJECT FORMAT (With the missing trailing bracket as per this question)
"{\"TS\": \"1642592890\", \"D\": \"19/01/2022 11:48:10\", \"slave\": \"172.16.0.3\", \"data\":\"25484,0,0,0,0\"}"

Do these suggested formats not been to be better than the current format? By encoding the fill string into the attribute name, it makes the use of JSON redundant, it may as well just be a string of some sort. Any software library used to parse the data would need to work through the attribute names and then parse those as JSON rather than just parsing the string via something normal such as JSON.parse("STRING").

I don't know if it's related but is the above the result of the option to "Send as object"? With this option enabled, it's difficult to encode multiple different items of data without making up an attribute name such as "data1", "data2" etc.

The only reasonable (and maybe very good solution) to the transmission of data "not as an object" is to take the suggestion of this question and use the request name as the attribute and then use the JSON string as the value.

Thanks.

1 Answer

0 votes
by
Hi,

Can you indicate the device and firmware version you are working with? Also, please, provide us with screenshots of your configuration and result to help us replicate the scenario.