title: REST API: fields of objects in a list of objects in response JSON
body: <p>Suppose we are building one-page app with two views: list view and detail view.</p>
  
  <p>In list view, we present a list of objects with just their names and maybe some more minimal data.</p>
  
  <p>In detail view, we present all possible fields of particular object.</p>
  
  <p>Hence the question: when we GET <code>/api/items/</code>, should we or should not to JSON-encode <strong>all</strong> fields of the objects listed, or just those presented in list view?</p>
  
  <p>In other words, if we show list of food like</p>
  
  <pre><code>Name     Price
  Potato   1
  Milk     2
  </code></pre>
  
  <p>does our API need to respond with JSON like this:</p>
  
  <pre><code>{ 
      [
           {
               "name": "Potato",
               "quantity": "1 kg",
               "origin": "Egypt", 
               "manufacturer": "Egypt Farmers",
               "price": 1,
               "packaging": "String bag",
               "_type": "Food"
           },
           {
               "name": "Milk",
               "quantity": "1 litre",
               "origin": "Finland", 
               "manufacturer": "Valio",
               "price": 2,
               "packaging": "Tetra Pak",
               "_type": "Food"
           },
      ]
  }
  </code></pre>
  
  <p>or like this:</p>
  
  <pre><code>{ 
      [
           {
               "name": "Potato",
               "price": 1,
               "_type": "Food"
           },
           {
               "name": "Milk",
               "price": 2,
               "_type": "Food"
           },
      ]
  }
  </code></pre>