Using Lift’s json parser, how can I output parsed json objects into a template?
The datatypes that net.liftweb.json.JsonParser provides are not
standard lists.
package rem.lift_client
package snippet
import net.liftweb._
import util._
import Helpers._
import net.liftweb.json.JsonParser._
class SearchResults {
def render() = {
val json_raw = "[ {\"userName\":\"John\"}, {\"userName\":\"Michael\"} ]"
val json_parsed = parse(input)
"li *" #> json_parsed.toString <---- NOT CORRECT
}
}
In the above example, I wanted to output a list of users as:
How do I interpret the parsed object? Any ideas are welcome, thanks.
NOTE: In addition to the accepted answer, lift-json has an excellent documentation on this subject.
One way is to extract the data with case classes.