0

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

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.