D
D
Dmtm2019-10-28 11:18:35
JSON
Dmtm, 2019-10-28 11:18:35

Is it possible to do incomplete json parsing in jackson?

{
  "type":"object",
  "properties": {
    "foo": {
      "type": "string"
    },
    "bar": {
      "type": "integer"
    },
    "baz": {
      "type": "boolean"
    }
  }
}

get object of type
data class BaseJsonObject(
    @JsonProperty("type")
    val type: String,
    @JsonProperty("properties")
    @JsonRawValue
    val properties: String
   )

where in properties - just a json string
while I only get Cannot deserialize instance of `java.lang.String` out of START_OBJECT token
or can't it be solved through annotations?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmtm, 2019-10-28
@Dmtm

a solution that suits me, if you need exactly a string, then apparently take it out of the Properties constructor and collect the string through a getter

data class BaseJsonObject(
    @JsonProperty("type")
    val type: String,
    @JsonProperty("properties")
    val properties: JsonNode
   )

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question