0

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

Vishal
  • 1,442
  • 3
  • 29
  • 48
  • Are you saying you have a JSONString whose value can also be parsed as JSON? Something like `{"data": "[1,2,3]"}` ? Can you show the complete input JSON document? – Thilo Feb 13 '18 at 06:56

1 Answers1

0
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)
}
atline
  • 28,355
  • 16
  • 77
  • 113