FasterXML/jackson-module-scala — Issue #12: Nested List and Map in Scala module
Author: JamiePullar
Created: 2012-01-10 10:13:36+00:00
State: open

I was suggested to raise this as an issue.

I wish to convert lists of json objects, which in themselves may contain Json objects, or Lists of Json objects and would like the results to be Scala Maps or Lists as appropriate, however, I can only get the top level object to convert to a Map or a List. Is there a simple way to do this?

For example in REPL

objectMapper.readValue("{\"test\":\"113123\",\"myList\":[{\"test2\":\"321323\"},{\"test3\":\"11122\"}]}", classOf[Map[String,Any]])
Will return

res: Map[String,Any] = Map(test -> 113123, myList -> [{test2=321323}, {test3=11122}])
Where I would like

res: Map[String,Any] = Map(test -> 113123, myList -> List(Map(test2 -> 321323), Map(test3 -> 111222)))