0

A simple ajax call to my server is giving me this json object. How to get the value of componentName or execution time ?

{"data":[{"date":"20131212","time":"103053","componentName":"xxxx","qualityIndexScore":{"noOfLinesOfCode":"47,214","coverage":"61.8%","violations":{"info":"43","minor":"215","major":"19","critical":"98"}},"liveScore":{"noOfErrors":"20313","executionTime":"2938596.2450000006"},"systemHealthScore":{},"dataBaseHealthScore":{}},{"date":"20131211","time":"110504","componentName":"yyyy","qualityIndexScore":{"noOfLinesOfCode":"342","coverage":"1.8%","violations":{"info":"21","minor":"53","major":"3","critical":"2"}},"liveScore":{"noOfErrors":"462","executionTime":"9298.1225000003"},"systemHealthScore":{},"dataBaseHealthScore":{}}]} 
Abhishek
  • 1,717
  • 6
  • 22
  • 39
  • `obj.data` is an array of objects. So, the 1st one would be `obj.data[0].componentName`. – gen_Eric Dec 12 '13 at 22:07
  • possible duplicate of [Access / process (nested) objects, arrays or JSON](http://stackoverflow.com/questions/11922383/access-process-nested-objects-arrays-or-json) – Felix Kling Dec 12 '13 at 22:07

1 Answers1

0

Depends which one in the array you want. Here is the output for first set.

console.log(data[0].componentName);
console.log(data[0].liveScore.executionTime);

Second set:

console.log(data[1].componentName);
console.log(data[1].liveScore.executionTime);

and so on...

KingKongFrog
  • 13,946
  • 21
  • 75
  • 124