我想以这种方式序列化我的类以2种不同的方式发送一个属性(作为一个字符串和一个枚举)与杰克逊序列化一个类。我如何确定杰克逊实际上将其他属性添加到JSON输出而不声明它?是否可以使用Jackson的其他属性进行序列化?
我的代码是
private LearningForm cnfpLearningOrganisationLearningForm;
......
/**
* @return the cnfpLearningOrganisationLearningForm
*/
public String getCnfpLearningOrganisationLearningFormSearch() {
return cnfpLearningOrganisationLearningForm.getValue();
}
/**
* @return the cnfpLearningOrganisationLearningForm
*/
public LearningForm getCnfpLearningOrganisationLearningForm() {
return cnfpLearningOrganisationLearningForm;
}
我想杰克逊序列化此为: { .... cnfpLearningOrganisationLearningForm:someValue中 cnfpLearningOrganisationLearningFormSearch:differentValue .... }
有一种没有将cnfpLearningOrganisationLearningFormSearch声明为类中的(除序列化外无用的)字段的方法?
谢谢。
我没有办法在该位置设置条件。不过谢谢,我会和JsonProperty一起玩,看看我能做些什么。 – Andrei 2012-07-27 13:19:16