I have parsed a json using lift-json parser in scala.I did this to parse the json object:
var parsedstring =parse(x)
The class of "parsedstring" is net.liftweb.json.JsonAST$JObject
Then I did this:
var parsedmap = (parsedstring.asInstanceOf[JObject].values)
The class of "parsedmap" is scala.collection.immutable.Map$Map1
then i did this:
var parsedactors = parsedmap("actors")
"actors" is key in parsedmap. Tha class of parsedactors is this: scala.collection.immutable.$colon$colon
I have to access elements of parsedactors. How can I do it?
scala.collection.immutable.$colon$colon
means it's a list, so you can access it eg via
val list = parsedmap("actors")
val first = list(0)
val second = list(1)
etc. Or you can map over it, use it in a for-comprehension, etc.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.