Since I am familiar with lift-json, I will show you how to do this with this library.
import net.liftweb.json.JsonDSL._ import net.liftweb.json.JsonAST._ import net.liftweb.json.Printer._ import net.liftweb.json.JObject val json: JObject = "names" -> List("Bob", "Andrea", "Mike", "Lisa") println(json) println(pretty(render(json)))
The expression names -> List(...) implicitly converted by JsonDSL, since I indicated that I wanted it to lead to a JObject , so now json is the json data model you wanted.
pretty comes from the Printer object, and render comes from the JsonAST object. Combined, they create a String representation of your data that looks like
{ "names":["Bob","Andrea","Mike","Lisa"] }
Be sure to check out the documentation where you are likely to find answers to any additional questions about json elevator support.
Dylan source share