Link to home
Start Free TrialLog in
Avatar of Rama Tito
Rama TitoFlag for Malaysia

asked on

Extract data from jsan format.

HI, In node red, I did create node to count number of rows in "mytab" table.
msg.topic  = "SELECT COUNT(count) FROM mytab"; 

return msg;

Open in new window


Result from node-red after count total number of row in mytab table is.

SELECT COUNT(count) FROM mytab : msg.payload : string[20]
"[{"COUNT(count)":8}]"

I am trying to extract number of rows, in this case it is --> 8.

var obj = msg.payload;
var json = JSON.parse(obj);
var Device = json[0].COUNT(count);
msg.payload = Device;
return msg;

Open in new window


Error msg after executing pop up saying : -
function : (error)
"ReferenceError: count is not defined (line 4, col 28)"
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Do :
var Device = j[0]["COUNT(count)"];

Open in new window


User generated image
Avatar of Rama Tito

ASKER

may i know why different. instead of j[0].Count(count) ? i couldn't get.
ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you