@JSONField注解的用法
@JSONField是fastjson中的一个注解。在属性头上加上这个注解中,在对对象进行json转换时,该属性,将不会参与格式化。
<span style="white-space:pre"> </span>@JSONField(serialize = false) private String id; private String billCode; private String pushTarget; private String pushCategory; private String pushTime; private String subscriptionCategory; private String subscriptionSource; private String createBy; private String orderCode; private String receiver_mobile; private String sender_mobile;
@Test public void tes3() { SubScriptEntity sub = new SubScriptEntity(); sub.setBillCode("1"); sub.setCreateBy("2"); sub.setId("3"); sub.setOrderCode("4"); sub.setPushCategory("5"); String json = JSON.toJSONString(sub); System.out.println(json); }run:
{"billCode":"1","createBy":"2","orderCode":"4","pushCategory":"5"}
id并没有转换被格式化。
原文链接:https://www.f2er.com/json/289603.html