简体   繁体   中英

How to Convert JSONString to JSONArray using Json4s

I am trying to convert the JSONString value to the JSONArray for further processing. Currently my JSONString value comes as

["a","b","c","d"]

now all I need is to convert this JSONString to JSON Array so that I can easily iterate over the values. How can we achieve this using Json4s

import org.json4s._
import org.json4s.native.JsonMethods._

val a= "[\"a\",\"b\",\"c\",\"d\"]"
val b = parse(a)
val c = b.values.asInstanceOf[List[String]]
for (d <- c) {
  println(d)
}

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM