I have a Json object coming back with the same property with different purposes based on the request (the resulting Json is out of my control). I only care about the property value when I make a specific request. Is there any way to use views for deserialization or something else that will conditionally propagate the pojo?
Example: Json
"boo":
{
"a": "foo"
}
"boo":
{
"a": { "x": 3 }
}
Java
public class Views {
public static class WhatIWant {}
public static class SomeOtherThings {}
}
public class Result {
@JsonView(View.WhatIWant)
public string a;
}
Result r = mapper.getDeserializationConfig()
.setDeserializationView(Views.WhatIWant.class)??
.readValue(node, Result.class);
As of Jackson 2.0, JSONViews are available for deserialization too.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With