title: Versioning a RESTful API with both XML and JSON Content-Type
body: <p>According to <a href="https://speakerdeck.com/u/dzuelke/p/designing-http-interfaces-and-restful-web-services-sfliveparis2012-2012-06-08" rel="noreferrer">this excellent presentation</a> on designing RESTful interfaces, the preferred way to implement versioning is to utilize the Accept-header, using something like:</p>
  
  <pre><code>GET /products HTTP/1.1
  Host: example.com
  Accept: application/vnd.com.myservice.v2+xml
  </code></pre>
  
  <p>This works perfectly for XML Content-Types, but <strong>is possible to use the same scheme for versioning the JSON-equivalent</strong>? </p>
  
  <p>I.e, is it possible to ask for:</p>
  
  <pre><code>GET /products HTTP/1.1
  Host: example.com
  Accept: application/vnd.com.myservice.v2+json
  </code></pre>
  
  <p>The response would be something like:</p>
  
  <pre><code>HTTP/1.1 200 OK
  Content-Type: application/vnd.com.myservice.v2+xml; charset=UTF-8
  Allow: GET, POST
  
  &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;products xmlns="urn:com.example.products" 
            xmlns:xl="http://www.w3.org/1999/xlink"&gt;
    &lt;product id="1234" xl:type="simple" 
             xl:href="http://example.com/products/1234"&gt;
      &lt;name&gt;Red Stapler&lt;/name&gt;
      &lt;price currency="EUR"&gt;3.14&lt;/price&gt;
      &lt;availability&gt;false&lt;/availability&gt;
    &lt;/product&gt;
  &lt;/products&gt;
  </code></pre>
  
  <p>and the JSON equivalent (sort of):</p>
  
  <pre><code>HTTP/1.1 200 OK
  Content-Type: application/vnd.com.myservice.v2+json; charset=UTF-8
  Allow: GET, POST
  
  [
    {
      id: "1234",
      links: [
        {
          rel: "self",
          href: "http://example.com/products/1234"
        }
      ],
      name: "Red Stapler",
      price: {
        currency: "EUR",
        value: 3.14
      },
      availability: false
    }
  ]
  </code></pre>