title: How to parse JSON with variable keys in Scala Play?
body: <p>Happy new years, first of all!</p>
  
  <p>I'm having some problem parsing JSON in Play, the format I'm dealing with is as follows:</p>
  
  <pre><code>JSON Response:
  
   ...
  "image":{  
      "large":{  
        "path":"http://url.jpg",
        "width":300,
        "height":200
      },
      "medium":{  
        "path":"http://url.jpg",
        "width":200,
        "height":133
      },
      ...
   }
  ...
  </code></pre>
  
  <p>I'm stuck on the field with the sizes. They are obviously variables, and I'm not sure how to write a formatter for this? The JSON is coming from an external service.</p>
  
  <p>So far I have</p>
  
  <pre><code>final case class Foo(
    ..
    ..
    image: Option[Image])
  
  
  final case class Image(size: List[Size])
  
  final case class Size(path: String, width: Int, height: Int)
  </code></pre>
  
  <p>For the formatting I just did <code>Json.reads[x]</code> for all the classes. However I'm pretty sure that the variable for size is throwing off the formatting because it's not able to create an Image object from the JSON coming in.</p>