gpt4 book ai didi

java - JACKSON 如何不包含字段的包装器?

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:14:29 27 4
gpt4 key购买 nike

JACKSON 如何不包含字段的包装器?

public  class AuthType {
Map<String,String> properties;

public Map<String, String> getProperties() {
return properties;
}

public void setProperties(Map<String, String> properties) {
this.properties = properties;
}

}

返回

{"properties":{"authType":"XYZ"}}

但我想拥有

{"authType":"XYZ"}

有注释吗?

看起来不支持它http://jira.codehaus.org/browse/JACKSON-765任何解决方法?

最佳答案

从 Jackson 1.9 开始,您可以使用 @JsonUnwrapped注释

public  class AuthType {
Map<String,String> properties;

@JsonUnwrapped
public Map<String, String> getProperties() {
return properties;
}

public void setProperties(Map<String, String> properties) {
this.properties = properties;
}
}

关于java - JACKSON 如何不包含字段的包装器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9106016/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com