mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-08-18 20:38:02 +08:00
add config
This commit is contained in:
25
hutool-json/src/test/java/cn/hutool/json/TransientTest.java
Normal file
25
hutool-json/src/test/java/cn/hutool/json/TransientTest.java
Normal 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());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user