Say I have JSON as such:
{
"field":{
"nested":{
"foo":"foo val",
"bar":"bar val",
},
"toignore1":{
},
"toignore2":{
}
}
}
I can’t seem to parse this correctly, and since it’s possible I don’t know all the fields to ingore, e.g. toignore3…, I don’t want to call them out in the models. I just need a few values from the whole response. If JSON_STRING represents the JSON above, why can’t I do this when parsing with Jerkson?
case class JsonModel(val field: FieldModel)
case class FieldModel(val nested: NestedModel) // ignoring other stuff here
case class NestedModel(val foo: String, bar: String)
val parsed = parse[JsonModel](JSON_STRING)
You can do this one of two ways: