You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 23, 2024. It is now read-only.
// 有一个会抛异常方法的JavaBean
public static class Model {
private int id;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
throw new IllegalStateException(); // 抛异常
}
}
// 测试代码
Model model = new Model();
model.setId(1001);
String text = JSON.toJSONString(model, SerializerFeature.IgnoreErrorGetter);
Assert.assertEquals("{\"id\":1001}", text);