在我的Java IDE中,我告诉java我为我的字段使用了前缀。
结果是在Java到Json序列化期间,我得到了所有以_
为前缀的属性,有一种简单的方法吗?
实际
{
"_creation": {
"_dateTime": "2016-08-16T11:13:09.000Z",
"_personId": 1
},
"_description": null,
"_firstName": "Jason",
"_id": 700,
"_lastName": "Stateman",
"_modification": {
"_dateTime": "2016-08-16T11:13:24.000Z",
"_personId": null
}
}
通缉
{
"creation": {
"dateTime": "2016-08-16T11:13:09.000Z",
"personId": 1
},
"description": null,
"firstName": "Jason",
"id": 700,
"lastName": "Stateman",
"modification": {
"dateTime": "2016-08-16T11:13:24.000Z",
"personId": null
}
}
答案 0 :(得分:1)
如果使用FasterXML序列化对象,可以将@JsonProperty注释添加到类属性中以控制序列化属性名称。请参阅以下文档:https://github.com/FasterXML/jackson-annotations/wiki/Jackson-Annotations#property-naming