fastjson对接口参数的某个字段不打印输出,如文件的base64字符串
package com.example.core.mydemo.json5; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.annotation.JSONField; /** 需要提供get set方法,如果使用@Data lombok 不生效(关键) ** public class Item { private String id; @JSONField(serialize = false) //fastjson 忽略字段打印 private String rate; public Item() { } public Item(String id, String rate) { this.id = id; this.rate = rate; } @Override public String toString() { return "Item{" + "id='" + id + '\'' + ", rate='" + rate + '\'' + '}'; } /** * output {"id":"111"} * @param args */ public static void main(String[] args) { Item item = new Item(); item.setId("111"); item.setRate("56666"); System.out.println(JSON.toJSONString(item)); } public String getId() { return id; } public void setId(String id) { this.id = id; } public String getRate() { return rate; } public void setRate(String rate) { this.rate = rate; } }
标签:fastjson,String,打印输出,对接口,public,Item,rate,id From: https://www.cnblogs.com/oktokeep/p/17641851.html