I have a problem parsing a JSON to a Java class. I have read about Elasticsearch Search App APIs, and I have found responses are like this one:
{
"name": {"raw": "Hello world"},
"number": {"raw": 7.5}
}
That is, every field is an object with a key called raw
and the real value I want. I would like to have a Java class like this one:
public class MyClass {
private String name;
private Double number;
}
I haven't seen in Jackson or any other mapping library something in order to map this JSON easily.
I would expect something like that if we use Jackson (is not a requisite, we could use any other parsing library):
ObjectMapper objectMapper = new ObjectMapper();
MyClass jsonParsed = objectMapper.readValue(json, MyClass.class);