使用Jackson进行输出时,是否可以将对象中的JSON输出字段重命名任意次数?
我可以使用一次JsonProperty
,如下所示,
How to map JSON field names to different object field names?
但是假设我有一个用于多个输出的类。在每个输出中,我都希望能够灵活地定义要更改的名称。
public class Study implements Serializable {
// Can vary as "id" / "studyId" depending on call
private int id;
// Can vary as "description" / "studyDescription" / "studyDesc" depending on call
private String description;
}
还是我需要为每种情况创建新对象?