The above is not strictly JSON, but JSONParser.parse seems to handle
this as well:
scala> import net.liftweb.util._
import net.liftweb.util._
scala> JSONParser.parse("{foo: [{bar: 'shiz'}, {bar: 'baz']}")
res0: net.liftweb.util.Box[Any] = Full(Map(foo -> List(Map(bar -> shiz))))
/Jeppe
If S.params("results") contain
Full(Map(name -> New Content, language -> en, content -> , id -> ext-
> record-1))
It seems like it's already parsed, in which case you could do
for (results <- S.params("results"); (key, value) <-results) {
Log.error(key + " -> " + value)
}
/Jeppe
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 <- S.params("results"); json <- JSONParser.parse(res)) json match {
case m: Map[_,_] => for((k,v) <- m) k match {
case "foo" => println("Found foo %s".format(v))
case y => println("Something else: %s".format(y))
}
case x => println("Didn't parse a map: %s".format(x))
}
/Jeppe
> 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
On 17 Jul., 08:59, Jeppe Nejsum Madsen <je...@ingolfs.dk> wrote:
> 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