title: How to convert Play Framework Models into XML and JSON?
body: <p>Does the Play Framework have a <strong>Native</strong> or <strong>Recommended</strong> way of converting Play models into XML/JSON? Something similar to JAXB or Jackson.</p>
  
  <p>Some people recommend the <a href="http://coffeebean.loicdescotte.com/2010/05/how-to-write-restxml-api-with-play.html" rel="nofollow noreferrer">template approach</a> but this is very verbose and doesn't guarantee well-formed XML/JSON.</p>
  
  <p>The <a href="http://www.playframework.org/documentation/2.0.4/JavaXmlRequests" rel="nofollow noreferrer">Play Documentation on XML</a> just shows an XML response being built using String concatenation like so:</p>
  
  <pre><code>return ok("&lt;message \"status\"=\"OK\"&gt;Hello " + name + "&lt;/message&gt;");
  </code></pre>
  
  <p>Similarly, the Play Documentation on JSON shows a JSON object being built up one line at a time.</p>
  
  <pre><code>ObjectNode result = Json.newObject();
  result.put("status", "OK");
  result.put("message", "Hello " + name);
  </code></pre>
  
  <p>Is there a <strong>Standard</strong> way of serializing Models into XML/JSON using Play?</p>
  
  <p>Is there any <strong>Official Play Documentation</strong> on this subject?</p>