/ / Come convertire JSONString in JSONArray usando Json4s - json, scala, json4s

Come convertire JSONString in JSONArray usando Json4s - json, scala, json4s

Sto cercando di convertire il valore JSONString in JSONArray per un'ulteriore elaborazione. Attualmente il mio valore JSONString viene come

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

ora tutto ciò di cui ho bisogno è di convertire questo JSONString in JSON Array in modo che possa facilmente scorrere i valori. Come possiamo ottenere questo utilizzando Json4s

risposte:

0 per risposta № 1
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)
}