JSON忽略指定屬性


  • https://blog.csdn.net/insis_mo/article/details/92760527
  • FastJson的使用方法:
  1. 在bean中的定義屬性上面使用注解@JSONField ,然后JSON.toJSONString()返回即可
  2. 使用SimplePropertyPreFilter指定序列化字段:SimplePropertyPreFilter filter = new SimplePropertyPreFilter(Bean.class, "FieldName"); 然后JSON.toJSONString()返回即可
  • JackSon的使用方法:
  1. 在Bean類名上使用@JsonIgnoreProperties({"fieldname1", "fieldName2"}), 然后(new ObjectMapper()).writeValueAsString(beanName);即可

  2. 在字段上使用@JsonIgnore,然后(new ObjectMapper()).writeValueAsString(beanName);即可


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM