-1

I have JSON with 2 collection FailedCount and SucceededCount.

{
 "FailedCount": [{
    "FailedCount_DATE_CURRENT_CHECK": "2016-11-30 10:40:09.0",
    "FailedCount_DATE__CURRENT__CHECK": "10:40:09",
    "FailedCount_MEAS_VALUE": 0
  }, {
    "FailedCount_DATE_CURRENT_CHECK": "2016-11-30 10:45:09.0",
    "FailedCount_DATE__CURRENT__CHECK": "10:45:09",
    "FailedCount_MEAS_VALUE": 0
  }, {
    "FailedCount_DATE_CURRENT_CHECK": "2016-11-30 10:50:09.0",
    "FailedCount_DATE__CURRENT__CHECK": "10:50:09",
    "FailedCount_MEAS_VALUE": 1
  }],
  "SucceededCount": [{
    "SucceededCount_MEAS_VALUE": 555
  }, {
    "SucceededCount_MEAS_VALUE": 547
  }, {
    "SucceededCount_MEAS_VALUE": 339
  }]
}

How get first value SucceededCount?

I tried:

jsonObj.SucceededCount[1];

But the result is not good: [object Object].

M.rumy
  • 33
  • 12
Nikolay Baranenko
  • 1,582
  • 6
  • 35
  • 60

2 Answers2

0

Try this

jsonObj.SucceededCount[0].SucceededCount_MEAS_VALUE;

Hope this helps.

Vermicello
  • 308
  • 1
  • 6
  • 11
0

Take the property SucceededCount of your object. You now have an array. Take the fist object of this array SucceededCount[0] and then select the property you need SucceededCount[0].SucceededCount_MEAS_VALUE

var obj = {
  "FailedCount": [{
    "FailedCount_DATE_CURRENT_CHECK": "2016-11-30 10:40:09.0",
    "FailedCount_DATE__CURRENT__CHECK": "10:40:09",
    "FailedCount_MEAS_VALUE": 0
  }, {
    "FailedCount_DATE_CURRENT_CHECK": "2016-11-30 10:45:09.0",
    "FailedCount_DATE__CURRENT__CHECK": "10:45:09",
    "FailedCount_MEAS_VALUE": 0
  }, {
    "FailedCount_DATE_CURRENT_CHECK": "2016-11-30 10:50:09.0",
    "FailedCount_DATE__CURRENT__CHECK": "10:50:09",
    "FailedCount_MEAS_VALUE": 1
  }],
  "SucceededCount": [{
    "SucceededCount_MEAS_VALUE": 555
  }, {
    "SucceededCount_MEAS_VALUE": 547
  }, {
    "SucceededCount_MEAS_VALUE": 339
  }]
};

console.log(obj.SucceededCount[0].SucceededCount_MEAS_VALUE);
Weedoze
  • 13,683
  • 1
  • 33
  • 63