1个父DTO
@JsonSerialize(include=JsonSerialize.Inclusion.NON_EMPTY)
public class OfferResponse {
@JsonProperty("Id")
private String id;
@JsonProperty("Status")
private String status;
@JsonProperty("Name")
private String name;
@JsonProperty("Offer")
private List<Offer> offers = null; // child dto Offer
}
2 Offer DOT是OfferResponse DTO的子代
@JsonSerialize(include = JsonSerialize.Inclusion.NON_EMPTY)
public class Offer {
@JsonProperty("Name")
private String name;
@JsonProperty("Type")
private String type;
@JsonProperty("Pricing")
private List<Pricing> pricing = null; // child dto Pricing
@JsonProperty("Timing")
private List<Timing> timing = null; // child dto Timing
}
3.1 定价DTO是要约DTO的子代
@JsonSerialize(include=JsonSerialize.Inclusion.NON_EMPTY)
public class Pricing {
@JsonProperty("Name") // in a response its coming name (?? why in lowercase while already given in title case
private String name;
@JsonProperty("Type") // in a response its coming type (?? why in lowercase while already given in title case
private String type;
@JsonProperty("SKU") //in a response its coming sku (?? why in lowercase while already given in title case
private String sKU;
}
3.2 //时间表DTO是要约DTO的子代
@JsonSerialize(include=JsonSerialize.Inclusion.NON_EMPTY)
public class Schedule {
@JsonProperty("Sample") // in a response its coming sample (?? why in lowercase while already given in title case
private String tier;
@JsonProperty("Lower")
}
但是在响应中,我在@JsonProperty的Title Case中给出了小写的子属性
响应:
{
"OfferResponse": {
"Id": "1234",
"Status": "SUCCESS",
"Name": "Sadina",
"Offer": [{
"Name": "Tata Docomo",
"Type": "PostPaid",
"Pricing": [{
"name": "100rs per month",
"type": "accessory",
"amount": "100",
"tpu": "4321"
}],
"Schedule": [{
"sample": "test for long"
}]
}]
}
}
鉴于上述回应即将到来,但我正在寻找所有属性标签都应为大写驼色的情况
答案 0 :(得分:-1)
您可以使用@JsonNaming(PropertyNamingStrategy.UpperCamelCaseStrategy.class)。这样会大写JSON消息中的所有属性名称。