I am trying to process an AJAX POST request in Play Framework 2.1.3. Mail data are JSON objects and have a tree structure, for example:
{ id: "a", name: "myname", kids : [{ id: "a1", name : "kid1", kids: []}, {id: "a2", name: "kid2", kids: [{id: "aa1", name :"grandkid", kids: []}]}]
I would like a nest of "children" arbitrarily deep. The class I would like to keep in mind is similar to this (I understand that recursiveness can be problematic):
case class Person { id: String, name: String, kids: Array[Person] }
The format I would like to keep in mind:
implicit val personFormat:Format[Person] = Json.format[Person]
The game throws errors in my format, which I wrote:
type mismatch; found: controller.Resources.Person required: Array [controller.Resources.Person]
I know that Play has a Tree structure. I could not find examples / documentation on how to link this to JSON reading.
Any help is much appreciated, thanks
Joost source share