-
Notifications
You must be signed in to change notification settings - Fork 6.5k
JSONField_jsonDirect_cn
wenshao edited this page May 21, 2016
·
1 revision
在fastjson-1.2.12版本中,JSONField支持一个新的配置项jsonDirect,它的用途是:当你有一个字段是字符串类型,里面是json格式数据,你希望直接输入,而不是经过转义之后再输出。
import com.alibaba.fastjson.annotation.JSONField;
public static class Model {
public int id;
@JSONField(jsonDirect=true)
public String value;
}
Model model = new Model();
model.id = 1001;
model.value = "{}";
String json = JSON.toJSONString(model);
Assert.assertEquals("{\"id\":1001,\"value\":{}}", json);
如有需要修改本注脚,请联系阿里巴巴,
© Alibaba Fastjson Develop Team
注明: 版权所有阿里巴巴,请注明版权所有者
If you need to amend this footnote, please contact Alibaba.
© Alibaba Fastjson Develop Team
Note: Copyright Alibaba, please indicate the copyright owner