Simply I have a POJO like this:
@JsonInclude(value=Include.NON_EMPTY)
public class Contact {
@JsonProperty("email")
private String email;
@JsonProperty("firstName")
private String firstname;
@JsonIgnore
private String subscriptions[];
...
}
When I create the JSON object using the JsonFactory
and ObjectMapper
, it would be something like:
{"email":"test@test.com","firstName":"testName"}
Now, the question is how can I generate something like the following without manual mapping.
{"properties": [
{"property": "email", "value": "test@test.com"},
{"property": "firstName", "value": "testName"}
]}
Note that, I know how to do manual mapping. Also, I need to use some features like Include.NON_EMPTY
.