0

When I alert the results I get following JSON data:

var results = JSON.stringify(result.results);
alert(results);

[{
    "test": "Connect_Disconnect222222",
    "jobid": "59",
    "os": "Windows NTeeeeeee",
    "report": "Verify Wireless Interface presenttttttttt and state is Disconnected:OK<br>Verify Profile not present on the Client:OK Client:OK<br>Verify Profile Not Present on the Client:OKffffffffffff<br>"
}]

How can I get the values report, test and jobid from that data?

1
  • 1
    JSON.stringify() converts a javascript object into string, so you won't be able to access those fields anymore. Commented Mar 8, 2014 at 11:00

2 Answers 2

3

The result.results is an array object, so you need to get the first item in the array and then fetch its properties

var record = result.results[0];
alert(record.test)
alert(record.jobid)
alert(record.report)
Sign up to request clarification or add additional context in comments.

4 Comments

[ { test: 'Connect_Disconnect222222', jobid: '81', os: 'Windows NTeeeeeee', report: 'Verify Wireless Interface presenttttttttt and state is Disconnected:OK<br>Verify Profile not present on the Client:OK Client:OK<br>Verify Profile Not Present on the Client:OKffffffffffff<br>' } ] from this also
what is this object.... if it is the same result.results then you can use the same code as above
console.log(testDetails[0].results); prints the above output.from this i have to get test and jobid..i triedconsole.log(testDetails[0].results.test); getting undefined
you need to use console.log(testDetails[0].results[0].test); because the results property is an array
0

When u use JsonArray u have to define the row number for example

alert(results[0].report);
alert(results[0].test);
alert(results[0].jobid);

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.