I want to read in a json object into a scala class that keeps part of the json object as a string without trying to parse it.
This is what the json looks like:
[
{
"contractType": "NullContract",
"contractDefinition": {
"column": "age",
"conditions": [
{
"conditionType": "equalsCondition",
"conditionDefinition": {
"column": "species",
"value": "person"
}
}
]
}
}
]
I am using the jackson library. This is my mapper:
val mapper = new ObjectMapper()
.registerModule(DefaultScalaModule)
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
.setSerializationInclusion(Include.NON_ABSENT)
This is my class:
case class ContractJson(contractType: String, contractDefinition: String)
, which is how I want my resulting object to look.
This is the code parsing it:
val contractJson: Array[ContractJson] = mapper.readValue(contractsJsonString, classOf[Array[ContractJson]])
Error message I'm getting: Can not deserialize instance of java.lang.String out of START_OBJECT token when it starts parsing the contractDefinition