title: Confused on using JSON Object for this
body: <p>Using Javascript I want to have a JSON or array that will store <code>id</code> &amp; <code>ip</code> data pairs, such that if I want the <code>ip</code> of a particular <code>id=123</code>, I can easily get it, ie by using <code>data[123]</code> or <code>data['123']['ip']</code>.</p>
  
  <p>I tried this but cant seem to select the <code>ip</code> based on <code>id</code>: </p>
  
  <pre><code>var connected_clients = {
      "clients": [{id: "12345", ip: "123.123.123.123"}]
  };
  </code></pre>
  
  <p>Also tried using this below, but I cant seem to add new id/ip pairs to it...</p>
  
  <pre><code>var connected_clients = {
      "12345": {
          id: "12345",
          ip: "123.123.123.123"
      }
  };
  </code></pre>
  
  <p>How should it be done?</p>