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?
2 Answers 2
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)
answered Mar 8, 2014 at 11:00
Arun P Johny
389k68 gold badges533 silver badges532 bronze badges
Sign up to request clarification or add additional context in comments.
4 Comments
Sush
[ { 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 alsoArun P Johny
what is this object.... if it is the same
result.results then you can use the same code as aboveSush
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 undefinedArun P Johny
you need to use
console.log(testDetails[0].results[0].test); because the results property is an arrayWhen u use JsonArray u have to define the row number for example
alert(results[0].report);
alert(results[0].test);
alert(results[0].jobid);
answered Mar 8, 2014 at 11:00
Kodr.F
14.5k13 gold badges57 silver badges101 bronze badges
Comments
lang-js
JSON.stringify()converts a javascriptobjectintostring, so you won't be able to access those fields anymore.