my question is that I want to use the same class to deserialize and re-serialize two different Jsons. I try to explain better. I have these Jsons:
{
"flavors": [
{
"id": "52415800-8b69-11e0-9b19-734f1195ff37",
"name": "256 MB Server",
"ram": 256,
"OS-FLV-DISABLED:disabled":true
"links": [
{
"rel": "self",
"href": "http://www.myexample.com"
},
{
"rel": "bookmark",
"href":"http://www.myexample.com"
}
]
},
...
}
{
"flavors": [
{
"id": "52415800-8b69-11e0-9b19-734f1195ff37",
"name": "256 MB Server",
"links": [
{
"rel": "self",
"href": "http://www.myexample.com"
},
{
"rel": "bookmark",
"href":"http://www.myexample.com"
}
]
},
...
}
As you can see, JSON B has all the fields JSON A except for "ram" and "OS-FLV-DISABLED: disabled." Used classes:
public class Flavor {
private String name;
private List<Link> links;
private int ram;
private boolean OS_FLV_DISABLED_disabled;
}
@XmlRootElement
public class GetFlavorsResponse {
private List<Flavor> flavors;
}
Also, just above the getter isOS_FLV_DISABLED_disabled method, I posted the annotation @XmlElement(name = "OS-FLV-DISABLED:disabled")
otherwise Jackson does not recognize this property. Here is the situation diagram:

When I get JSON A, there is no problem, the JSON result is again JSON A; but when I get JSON B, the result of serializing the serialization of the process is:
{
"flavors": [
{
"id": "52415800-8b69-11e0-9b19-734f1195ff37",
"name": "256 MB Server",
"ram": 0,
"OS-FLV-DISABLED:disabled":false
"links": [
{
"rel": "self",
"href": "http://www.myexample.com"
},
{
"rel": "bookmark",
"href":"http://www.myexample.com"
}
]
},
...
}
, , , , Json
, 0 "ram"
"OS-FLV-: ".
@JsonSerialize(include=JsonSerialize.Inclusion.NON_DEFAULT)
Flavor. , , JSON A, "ram" "OS-FLV-DISABLED: disabled" 0 false ( ), JSON B, .
, , , , @JsonView @JsonFilter, , .
, .