Я пытаюсь преобразовать json в объект scala, но поля не инициализированы.
object MyJson {
val myJson =
"""{
"addresses":{
"address":[
{
"addressLine1":{
"com.jacksontest.AddressLine":{
"value":null,
"transliteratedValue":null,
"naCode":null
}
},
"addressLine2":{
"com.jacksontest.AddressLine":{
"value":{
"string":"MY ADDRESS"
},
"transliteratedValue":null,
"naCode":null
}
}
}
]
}
}"""
}
case class Organization(addresses: Addresses)
case class AddressLine(value: StringWrapper,
transliteratedValue: String,
naCode: String)
case class Address(addressLine1: AddressLine,
addressLine2: AddressLine)
case class Addresses(address: List[Address])
case class StringWrapper(string: String)
object Main {
val mapper = new ObjectMapper() with ScalaObjectMapper
mapper.registerModule(DefaultScalaModule)
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
def main(args: Array[String]): Unit = {
val parsedJson = mapper.readValue(MyJson.myJson, classOf[Organization])
println(parsedJson)
}
}
Мой результат:
Организация (Адреса (Список (Address (AddressLine (null,null, null), AddressLine (null, null, null)))))
Что я делаю не так?