Extract data from array json format.

I am extracting all data from mysql using Node-Red. Its give set of data in json format but with opening and closing quote to indicate as string format. I did try many ways to pull out particular line.

" [   {"ID":1,"DeviceId":2,"Line":1,"outPIN":"7","count":1,"Time":"2018-09-16T13:28:24.000Z","IdRef":1} ,
       {"ID":2,"DeviceId":2,"Line":1,"outPIN":"7","count":1,"Time":"2018-09-16T13:29:53.000Z","IdRef":1} ,
       {"ID":3,"DeviceId":2,"Line":1,"outPIN":"7","count":1,"Time":"2018-09-16T13:29:59.000Z","IdRef":1} ,
       {"ID":4,"DeviceId":2,"Line":1,"outPIN":"7","count":1,"Time":"2018-09-16T13:39:15.000Z","IdRef":1} ,
       {"ID":5,"DeviceId":2,"Line":1,"outPIN":"7","count":1,"Time":"2018-09-16T13:39:16.000Z","IdRef":1} ,
       {"ID":6,"DeviceId":2,"Line":1,"outPIN":"7","count":1,"Time":"2018-09-16T13:39:16.000Z","IdRef":1} ,
       {"ID":7,"DeviceId":2,"Line":1,"outPIN":"7","count":1,"Time":"2018-09-16T13:39:17.000Z","IdRef":1} ,
       {"ID":8,"DeviceId":2,"Line":1,"outPIN":"7","count":1,"Time":"2018-09-16T13:39:17.000Z","IdRef":1}   ] "

var obj = msg.payload;
var json = JSON.parse(obj);

var Device = json[1].Device_ID;
msg.payload = Device;
returen msg;

Open in new window


Error message as follows :

SELECT *FROM mytab : msg.payload : undefined
undefined
Rama TitoProgrammerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

leakim971PluritechnicianCommented:
it's DeviceId and not Device_ID here :
var Device = json[1].Device_ID;

Open in new window


DeviceId
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
leakim971PluritechnicianCommented:
a good tools : http://jsonviewer.stack.hu/

[{"ID":1,"DeviceId":2,"Line":1,"outPIN":"7","count":1,"Time":"2018-09-16T13:28:24.000Z","IdRef":1},{"ID":2,"DeviceId":2,"Line":1,"outPIN":"7","count":1,"Time":"2018-09-16T13:29:53.000Z","IdRef":1},{"ID":3,"DeviceId":2,"Line":1,"outPIN":"7","count":1,"Time":"2018-09-16T13:29:59.000Z","IdRef":1},{"ID":4,"DeviceId":2,"Line":1,"outPIN":"7","count":1,"Time":"2018-09-16T13:39:15.000Z","IdRef":1},{"ID":5,"DeviceId":2,"Line":1,"outPIN":"7","count":1,"Time":"2018-09-16T13:39:16.000Z","IdRef":1},{"ID":6,"DeviceId":2,"Line":1,"outPIN":"7","count":1,"Time":"2018-09-16T13:39:16.000Z","IdRef":1},{"ID":7,"DeviceId":2,"Line":1,"outPIN":"7","count":1,"Time":"2018-09-16T13:39:17.000Z","IdRef":1},{"ID":8,"DeviceId":2,"Line":1,"outPIN":"7","count":1,"Time":"2018-09-16T13:39:17.000Z","IdRef":1}]

Open in new window


JSON Viewer
0
Rama TitoProgrammerAuthor Commented:
Thank you , Do appreciate most
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JSON

From novice to tech pro — start learning today.