title: In Play, when rendering JSON can I use anonymous types and/or object initializers?
body: <p>I'm writing a Play application that will have dozens of controller actions that return JSON. The format of each JSON result is slightly different, built up from a few primitives.</p>
  
  <p>I would like to avoid creating a Java class to hold the return type for each action method, so currently I am using a HashMap, like this:</p>
  
  <pre><code>// used to populate the filters for an iphone app
  public static void filters()
  {
      // get four lists from the database
      List&lt;Chef&gt; chefs= Chef.find("order by name asc").fetch();
      List&lt;Cuisine&gt; cuisines = Cuisine.find("order by name asc").fetch(); 
      List&lt;Meal&gt; meals  = Meal.find("order by name asc").fetch(); 
      List&lt;Ingredient&gt; ingredients = Ingredient.find("order by name asc").fetch(); 
      // return them as JSON map
      Map&lt;String,Object&gt; json = new HashMap&lt;String,Object&gt;();
      json.put("chefs", chefs);
      json.put("cuisines", cuisines);
      json.put("meals", meals);
      json.put("ingredients", ingredients);
      renderJSON(json);
  }
  </code></pre>
  
  <p>This returns JSON that looks like this, which is what I want:</p>
  
  <pre><code>{ 
    "chefs": [{},{},...{}],
    "cuisines": [{},{},...{}],
    "meals": [{},{},...{}],
    "ingredients": [{},{},...{}]
  }
  </code></pre>
  
  <p>I feel like <strong>the syntax to construct the HashMap is redundant</strong>. I don't have a ton of Java experience, so I'm comparing to C# which lets me use an <em>anonymous type</em> with an <em>object initializer</em>, to cut down on the code like so:</p>
  
  <pre><code>return Json(new
  {
      chefs = chefs,
      cuisines = cuisines,
      meals = meals,
      ingredients = ingredients
  });
  </code></pre>
  
  <p><strong>Is there anything in the Java/Play world that let's me write this kind of code more compactly?</strong></p>