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