Most of the time what I use lift json I start by starting the repl,
assigning the json I want to work with to a value and then look at the
parsed result to construct a case class or a group of them. Is there a
way to have lift json generate the case classes for me? even if it
would end up copying and pasting it on my code.
Sample session:
scala> val json= """
| {"results":[
| {"seq":31,"id":"1","changes":[{"rev":"30-228b36767c332568d40a71438b672877"}]},
| {"seq":32,"id":"2","changes":[{"rev":"2-92a882a939a8150f6770bb2eaace2301"}]}
| ],
| "last_seq":32}
| """
json: java.lang.String =
"
{"results":[
{"seq":31,"id":"1","changes":[{"rev":"30-228b36767c332568d40a71438b672877"}]},
{"seq":32,"id":"2","changes":[{"rev":"2-92a882a939a8150f6770bb2eaace2301"}]}
],
"last_seq":32}
"
scala> val p= parse(json)
p: net.liftweb.json.package.JValue =
JObject(List(JField(results,JArray(List(JObject(List(JField(seq,JInt(31)),
JField(id,JString(1)),
JField(changes,JArray(List(JObject(List(JField(rev,JString(30-228b36767c332568d40a71438b672877))))))))),
JObject(List(JField(seq,JInt(32)), JField(id,JString(2)),
JField(changes,JArray(List(JObject(List(JField(rev,JString(2-92a882a939a8150f6770bb2eaace2301)))))))))))),
JField(last_seq,JInt(32))))
scala>
and now I look at the result of p and start writing my case class/es
Thanks
Diego
--
Diego Medina
Web Developer
di...@fmpwizard.com
http://www.fmpwizard.com
Thanks Joni!
Diego
Sent from my android cell
--
Lift, the simply functional web framework: http://liftweb.net
Code: http://github.com/lift
Discussion: http://groups.google.com/group/liftweb
Stuck? Help us help you: https://www.assembla.com/wiki/show/liftweb/Posting_example_code