在POJO中删除自动显示吸气剂 [英] Remove the automatically display of getter in POJO
本文介绍了在POJO中删除自动显示吸气剂的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
下面,我给出了我的POJO结构以及当前的输出和预期的输出.我的要求是,当我打印JSON格式时,称为"applicationUsage"的变量会自动包含在我的输出JSON中作为键,但是我不想以JSON格式添加"applicationUsage"键,而只想显示存储在此值中的值场地.谁能帮我提供代码.
Below I have given my POJO structure and the current out put and expected output. My requirement is, when I am printing the JSON format the variable called "applicationUsage " automatically included in my output JSON as key, But I dont want to add "applicationUsage " key in my json format and only wants to show the values stored in this field. Can anyone help me with the code.
@JsonRootName(value = "MediationUserCacheRequest")
@JsonTypeInfo(include = As.WRAPPER_OBJECT, use = Id.NAME)
@JsonTypeName(value = "MediationUserCacheRequest")
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({ "eventName", "eventType", "action" })
public class MedationUsageReport implements Serializable {
private final static long serialVersionUID = -2077028266055844229L;
@JsonProperty("eventName")
private String eventName;
@JsonProperty("eventType")
private String eventType;
@JsonProperty("action")
private String action;
private Map<String, List<MediationApplicationUsageResport>> applicationUsage = null;
@JsonProperty("eventName")
public String getEventName() {
return eventName;
}
@JsonProperty("eventName")
public void setEventName(String eventName) {
this.eventName = eventName;
}
@JsonProperty("eventType")
public String getEventType() {
return eventType;
}
@JsonProperty("eventType")
public void setEventType(String eventType) {
this.eventType = eventType;
}
@JsonProperty("action")
public String getAction() {
return action;
}
@JsonProperty("action")
public void setAction(String action) {
this.action = action;
}
public Map<String, List<MediationApplicationUsageResport>> getApplicationUsage() {
return applicationUsage;
}
public void setApplicationUsage(Map<String, List<MediationApplicationUsageResport>> applicationUsage) {
this.applicationUsage = applicationUsage;
}
}
输出:
{"MediationUserCacheRequest":{"eventName":"STORAGE","eventType":"CURRENT_USAGE","action":"usagereport","applicationUsage":{"nuxeo":[ ...
想要:
{"MediationUserCacheRequest":{"eventName":"STORAGE","eventType":"CURRENT_USAGE","action":"usagereport",{"nuxeo":[ ...
推荐答案
只需使用@JsonAnyGetter批注对其进行标记.
Simply mark it with @JsonAnyGetter annotation.
@JsonAnyGetter
public Map<String, List<MediationApplicationUsageResport>> getApplicationUsage() {
return applicationUsage;
}
这篇关于在POJO中删除自动显示吸气剂的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文