Scala deserialize JSON to Collection
Scala deserialize JSON to Collection My JSON File containes below details { "category":"age, gender,post_code" } My scala code is below one val filename = args.head println(s"Reading ${args.head} ...") val json = Source.fromFile(filename) val mapper = new ObjectMapper() with ScalaObjectMapper mapper.registerModule(DefaultScalaModule) val parsedJson = mapper.readValue[Map[String, Any]](json.reader()) val data = parsedJson.get("category").toSeq It's returning Seq(Any) = example List(age, gender,post_code) but I need Seq(String) output please if any has an idea about this please help me. 2 Answers 2 The idea in scala is to be typesafe whenever possible which you are giving away using Map[String, Any] . Map[String, Any] So, I recommend using a data class that represents your JSON data. Example, define a mapper, scala> import com.fasterxml.jackson.databind...