title: RESTful API: How to model JSON representation?
body: <p>I am designing a RESTful API for a booking application. You can request a list of accommodations. And that's where I don't really know how to design the JSON represenation. This is my XML representation:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;accommodations&gt;
      &lt;accommodation&gt;
          &lt;name&gt;...&lt;/name&gt;
          &lt;category&gt;couch&lt;/category&gt;
      &lt;/accommodation&gt;
      &lt;accommodation&gt;
          &lt;name&gt;...&lt;/name&gt;
          &lt;category&gt;room&lt;/category&gt;
      &lt;/accommodation&gt;
  &lt;accommodations&gt;
  </code></pre>
  
  <p>My first try to convert this to JSON resulted in this output (1):</p>
  
  <pre><code>{
      "0": {
          "name": "...",
          "category": "couch"
      },
      "1": {
          "name": "...",
          "category": "room"
      }
  }
  </code></pre>
  
  <p>But as I looked how others APIs did it, I found something looking more like this (2):</p>
  
  <pre><code>[
      {
          "name": "...",
          "category": "couch" 
      },
      {
          "name": "...",
          "category": "room" 
      }
  ]
  </code></pre>
  
  <p>I know version 1 is an object, and version 2 an array. </p>
  
  <p>But which one is better in this case?</p>