i have following json data.from this i need to extract os value. How it can be done using node.js
result = data.toString();
console.log(result) prints following
[ { _id: '52849a7b8dd61980d1b49b87',
id: '70',
mode: 'daily',
os: 'VM-WIN7-64',
server: '172.16.2.120' } ]
i tried console.log(result.os); prints undefined!
How can i get os value
asked Nov 14, 2013 at 11:39
Sush
1,4579 gold badges27 silver badges51 bronze badges
1 Answer 1
Assuming data is an array you should be able to do this:
console.log(data[0].os);
Why are you calling toString on data? That will return a string, which obviously isn't going to have an os property. You need to work with the actual data structure.
answered Nov 14, 2013 at 11:41
James Allardice
166k22 gold badges335 silver badges316 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
lang-js