title: How to read both single object & array of objects in json using javascript/jquery
body: <p>I  wrote the json reader to read the data &amp; works fine with the below data.</p>
  
  <pre><code>{"menu": {
    "id": "file",
    "value": "File",
    "popup": {
      "menuitem": [
        {"value": "New", "onclick": "CreateNewDoc()"},
        {"value": "Open", "onclick": "OpenDoc()"},
        {"value": "Close", "onclick": "CloseDoc()"}
      ]
    }
  }}
  </code></pre>
  
  <p>but the when json returns the single menuitem from api like </p>
  
  <pre><code>{"menu": {
    "id": "file",
    "value": "File",
    "popup": {
      "menuitem": 
        {"value": "Close", "onclick": "CloseDoc()"}
  
    }
  }}
  </code></pre>
  
  <p>menuitem is an object instead of an array.
  So, my json reader is failing to read as i'm readin the array of menuitem by looping.</p>
  
  <p>solution is greatly appreciated.
  How this is handled by other major sites?</p>