忽略字段
由对象转换为json字符串时,增加@JSONField(serialize = _false_)
即可
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
@Data
public class Person {
@JSONField(serialize=false)
private String id;
private String name;
private Integer age;
}
带泛型的gson转换
JsonElement labels = item.get("labels");
if (ObjectUtils.isNotEmpty(labels)) {
Type type = new TypeToken<List<String>>() {
}.getType();
List<String> labelList = GSON.fromJson(GSON.toJson(labels), type);
if (ObjectUtils.isNotEmpty(labelList)) sheet.setLabels(String.join(" ", labelList));
}