标题翻译
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<Tag> tags;
...
...
ex:
{
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
},
专注分享java语言的经验与见解,让所有开发者获益!
评论