Hi,

There's several ways to get values from JSON.

1. Use LINQ style query comprehension:

for { JField("bar", JInt(x)) <- json } yield x

2. Extract values with case classes

implicit val formats = net.liftweb.json.DefaultFormats
case class Foo(foo: Bar)
case class Bar(bar: Int)
json.extract[Foo]

3. XPath style

val JField("bar", JInt(x)) = json \ "foo" \ "bar"

Cheers Joni

On 19 marras, 22:20, harryh <[email protected]> wrote:
> Is there a basic intro to lift-json floating around anywhere?  I'm
> having a bit of trouble getting started with a couple basic things.
> For example if a have a JObject that corresponds to:
>
> {
>   "foo" : {
>     "bar" : 999
>   }
>
> }
>
> How do I get the 999 (as an int) out of the JObject?  I'm sure this is
> simple, just a bit confused on the basics.
>
> -harryh

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=.


Reply via email to