add config

This commit is contained in:
Looly
2020-07-31 09:43:05 +08:00
parent dd7f04af44
commit f6f97668cf
5 changed files with 174 additions and 71 deletions

View File

@@ -0,0 +1,25 @@
package cn.hutool.json;
import lombok.Data;
import org.junit.Assert;
import org.junit.Test;
public class TransientTest {
@Data
static class Bill{
private transient String id;
private String bizNo;
}
@Test
public void beanWithTransientTest(){
Bill detailBill = new Bill();
detailBill.setId("3243");
detailBill.setBizNo("bizNo");
final JSONObject jsonObject = new JSONObject(detailBill,
JSONConfig.create().setIgnoreTransient(true));
Assert.assertEquals("{\"bizNo\":\"bizNo\"}", jsonObject.toString());
}
}