Jackson:将带有标签列表的对象序列化

huangapple 未分类评论73阅读模式
标题翻译

Jackson: Serializing object with list of tags

问题

{
    "SnapshotIdentifier": 'rs:dnd-1',
    "ClusterIdentifier": 'dnd-1',
    "SnapshotCreateTime": '2020-03-03T17:58:46.173Z',
    "SnapshotType": 'automated',
    "Status": 'available',
    "Tags": [{ "Key": "test", "Value": "my-tag" }] //<--- need to convert `Key` and `Value` to capitalized just like other properties
}
英文翻译

I'm trying to serialize Java POJO into Json with capitalized property names. I'm using @JsonNaming(PropertyNamingStrategy.UpperCamelCaseStrategy.class) for that and for the most part its working correctly except for Tags list. The the property names are still coming as lower case. What do I need to make them capitalized?


@JsonNaming(PropertyNamingStrategy.UpperCamelCaseStrategy.class)
public class Snapshot implements Serializable {
    private String snapshotIdentifier;
    private String clusterIdentifier;
    private Date snapshotCreateTime;
    private String snapshotType;
    private String status;
    private List&lt;Tag&gt; tags;

   ...
   ...
   

ex:

{
        SnapshotIdentifier: &#39;rs:dnd-1&#39;,
        ClusterIdentifier: &#39;dnd-1&#39;,
        SnapshotCreateTime: &#39;2020-03-03T17:58:46.173Z&#39;,
        SnapshotType: &#39;automated&#39;,
        Status: &#39;available&#39;,
        Tags: [{ key: &quot;test&quot;, value: &quot;my-tag&quot; }] &lt;--- need to convert `key` and `value` to capitalized just like other properties
      },

huangapple
  • 本文由 发表于 2020年3月4日 05:29:59
  • 转载请务必保留本文链接:https://java.coder-hub.com/60515820.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定