[Lift] Re: Parsing JSON POST

2009-07-29 Thread David Pollak
On Fri, Jul 24, 2009 at 8:57 PM, fbettag fr...@bett.ag wrote: Still one problem when parsing: results: {name:New Content,language:en,content:,layout: 22} java.lang.NumberFormatException: For input string: 22.0 at java.lang.NumberFormatException.forInputString

[Lift] Re: Parsing JSON POST

2009-07-17 Thread Jeppe Nejsum Madsen
David Pollak feeder.of.the.be...@gmail.com writes: You can use: Box.asA[Map[String, _]](in) which will return Full(in) if in is a Map[String, _] or Empty if it's not. This helps in for comprehensions. Ah, didn't know that. Very nice! /Jeppe

[Lift] Re: Parsing JSON POST

2009-07-16 Thread David Pollak
You can use: Box.asA[Map[String, _]](in) which will return Full(in) if in is a Map[String, _] or Empty if it's not. This helps in for comprehensions. On Wed, Jul 15, 2009 at 12:00 PM, Jeppe Nejsum Madsen je...@ingolfs.dkwrote: On Wed, Jul 15, 2009 at 11:27 AM, fbettagfr...@bett.ag wrote:

[Lift] Re: Parsing JSON POST

2009-07-15 Thread fbettag
I just noticed i forgot a } after 'baz' ;) Thanks for your replies On Jul 14, 6:59 pm, Jeppe Nejsum Madsen je...@ingolfs.dk wrote: fbettag fr...@bett.ag writes: Heyho, any ideas how i can parse data that was posted as JSON? For example: {foo: [{bar: 'shiz'}, {bar: 'baz']} The above

[Lift] Re: Parsing JSON POST

2009-07-15 Thread fbettag
Ok, i found out that the POSTed JSON was in S.params(results).first, which contains: Full(Map(name - New Content, language - en, content - , id - ext- record-1)) So i tried this: for ((key, value) - JSONParser.parse(S.params(results).first)) { Log.error(key + - +

[Lift] Re: Parsing JSON POST

2009-07-15 Thread fbettag
Any variation i try gives me: (key, value) - res value filter is not a member of Any On Jul 15, 11:22 am, marius d. marius.dan...@gmail.com wrote: Try using for comprehensions  for (res - JSONParser.parse(S.params(results).first);       (key, value) - res) yield some_expression Marius

[Lift] Re: Parsing JSON POST

2009-07-15 Thread Jeppe Nejsum Madsen
On Wed, Jul 15, 2009 at 11:27 AM, fbettagfr...@bett.ag wrote: Any variation i try gives me: (key, value) - res value filter is not a member of Any Ahh yes, JSONParser.parse returns Box[Any] since the result can be either a list or a map. Still, you can do it like this for (res -