Read data from JSON array


#41

@ Andrei

Thanks, Sir, I did a quick testing which shows it works perfectly. Many thanks again!!.


#42

this is the json formatted file how to print some specific value
like only id value.
[
{
"id": "77fe19a.cdb9ee8",
"type": "debug",
"z": "31ac8dfb.337542",
"name": "",
"active": true,
"tosidebar": true,
"console": true,
"tostatus": false,
"complete": "payload",
"x": 646,
"y": 204,
"wires":
},
{
"id": "4f531964.dad328",
"type": "function",
"z": "31ac8dfb.337542",
"name": "print",
"func": "\nvar x = msg.payload;\nvar y= x * x;\nreturn { payload : y};\n",
"outputs": 1,
"noerr": 0,
"x": 375,
"y": 201,
"wires": [
[
"77fe19a.cdb9ee8"
]
]
},
{
"id": "4eaa8e0d.bdfb5",
"type": "inject",
"z": "31ac8dfb.337542",
"name": "",
"topic": "square",
"payload": "5",
"payloadType": "num",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 101,
"y": 204,
"wires": [
[
"4f531964.dad328"
]
]
}
]


#43

Hi Guys,
I have a similar problem parsing JSONarray , so maybe it is not worth to create new topic.
So I have a data incoming from small MCU with json format
{"filter1":[{"tap": 68},{"tap": -191},{"tap": 784},{"tap": 1482},{"tap": 736},{"tap": -161},{"tap": -1666},{"tap": -67},{"tap": 0},{"tap": 0},{"tap": 0},{"tap": 0}]}
and I want to plot it in the bar chart.
so every bar is filter tap.
problem is that I can't(don't know how to deserialize this json object.

my setup is follows - I'm reading from uart(serial in node)->JSON node-> function->chart

any suggestions and hints are welcome.
P.S.
I've tried :slight_smile:
var arr = msg.payload.filter1;
var msgs={ payload:[0]} ;

for(i=1; i < arr.length; i++){

msgs.payload.push(arr[i].tap);

}
return [msgs];
but I have error from node console:
19 Mar 14:46:24 - [warn] [ui_chart:66d0e46a.d1521c] Bad data inject
19 Mar 14:46:24 - [info] [debug:df333238.11b18]
[ -100, 931, 2170, 122, -452, -1279, -198, 0, 0, 0, 0 ]

is this error in parser function or in chart node?