title: How to get values in a JSON array object
body: <p>I am new to javascript usage.
  I have a requirement of below JSON object message.</p>
  <pre><code>{
    &quot;Rep&quot;: {
      &quot;out&quot;: [
        {
          &quot;first&quot;: &quot;abc&quot;,
          &quot;second&quot;: &quot;fd&quot;,
          &quot;state&quot;: &quot;none&quot;,
          &quot;badge&quot;: &quot;NON&quot;,
          &quot;res&quot;: 0
        },
        {
          &quot;first&quot;: &quot;xyz&quot;,
          &quot;second&quot;: &quot;5f7209&quot;,
          &quot;state&quot;: 15,
          &quot;badge&quot;: &quot;OH&quot;,
          &quot;res&quot;: 0
        },
        {
          &quot;first&quot;: &quot;def&quot;,
          &quot;second&quot;: &quot;b5fd&quot;,
          &quot;badge&quot;: &quot;Pen&quot;,
          &quot;state&quot;: 3,
          &quot;res&quot;: 0
        },
        {
          &quot;first&quot;: &quot;aa&quot;,
          &quot;second&quot;: &quot;5e&quot;,
          &quot;badge&quot;: &quot;Com&quot;,
          &quot;state&quot;: 1,
          &quot;res&quot;: 0
        }
      ]
    }
  }
  
  </code></pre>
  <p>The requirement is I have to traverse and take 'first' key tag value from the object and check whether the value equals to some value(here it is &quot;first&quot; == 'aa').
  if exists I have to take the value of 'badge' from the corresponding object.</p>
  <p>Example -
  From the message</p>
  <p>1)I have to check if &quot;first == aa&quot; exists, then I should check in the object 'res' value if it is 0,then take the value of badge, here it is &quot;com&quot;.</p>
  <p>2)I have to check if &quot;first == def&quot; exists, then I should  check in the object 'res' value if it is 0,then take the value of badge, here it is &quot;Pen&quot;.</p>
  <p>In the similar way I have to go through each block and check &quot;first&quot; key value and then take corresponding badge value.</p>
  <p>Note : We will not be not sure on how many object blocks will come in array.</p>