This commit is contained in:
Looly 2022-06-07 10:41:00 +08:00
parent 886a865aac
commit f985887406
16 changed files with 44 additions and 67 deletions

View File

@ -243,7 +243,7 @@ public class ConverterRegistry implements Serializable {
} }
// 无法转换 // 无法转换
throw new ConvertException("Can not Converter from [{}] to [{}]", value.getClass().getName(), type.getTypeName()); throw new ConvertException("Can not convert from {}: [{}] to [{}]", value.getClass().getName(), value, type.getTypeName());
} }
/** /**

View File

@ -201,7 +201,7 @@ public final class InternalJSONUtil {
static Map<String, Object> createRawMap(final int capacity, JSONConfig config) { static Map<String, Object> createRawMap(final int capacity, JSONConfig config) {
final Map<String, Object> rawHashMap; final Map<String, Object> rawHashMap;
if (null == config) { if (null == config) {
config = JSONConfig.create(); config = JSONConfig.of();
} }
final Comparator<String> keyComparator = config.getKeyComparator(); final Comparator<String> keyComparator = config.getKeyComparator();
if (config.isIgnoreCase()) { if (config.isIgnoreCase()) {

View File

@ -2,6 +2,8 @@ package cn.hutool.json;
import cn.hutool.core.bean.BeanPath; import cn.hutool.core.bean.BeanPath;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.convert.impl.ArrayConverter;
import cn.hutool.core.lang.func.Filter; import cn.hutool.core.lang.func.Filter;
import cn.hutool.core.lang.mutable.Mutable; import cn.hutool.core.lang.mutable.Mutable;
import cn.hutool.core.lang.mutable.MutableObj; import cn.hutool.core.lang.mutable.MutableObj;
@ -66,7 +68,7 @@ public class JSONArray implements JSON, JSONGetter<Integer>, List<Object>, Rando
* @since 3.2.2 * @since 3.2.2
*/ */
public JSONArray(final int initialCapacity) { public JSONArray(final int initialCapacity) {
this(initialCapacity, JSONConfig.create()); this(initialCapacity, JSONConfig.of());
} }
/** /**
@ -90,7 +92,7 @@ public class JSONArray implements JSON, JSONGetter<Integer>, List<Object>, Rando
*/ */
public JSONArray(final int initialCapacity, final JSONConfig config) { public JSONArray(final int initialCapacity, final JSONConfig config) {
this.rawList = new ArrayList<>(initialCapacity); this.rawList = new ArrayList<>(initialCapacity);
this.config = ObjUtil.defaultIfNull(config, JSONConfig::create); this.config = ObjUtil.defaultIfNull(config, JSONConfig::of);
} }
/** /**
@ -107,7 +109,7 @@ public class JSONArray implements JSON, JSONGetter<Integer>, List<Object>, Rando
* @throws JSONException 非数组或集合 * @throws JSONException 非数组或集合
*/ */
public JSONArray(final Object object) throws JSONException { public JSONArray(final Object object) throws JSONException {
this(object, JSONConfig.create()); this(object, JSONConfig.of());
} }
/** /**
@ -332,7 +334,7 @@ public class JSONArray implements JSON, JSONGetter<Integer>, List<Object>, Rando
@Override @Override
@SuppressWarnings({"unchecked"}) @SuppressWarnings({"unchecked"})
public <T> T[] toArray(final T[] a) { public <T> T[] toArray(final T[] a) {
return (T[]) JSONConverter.toArray(this, a.getClass().getComponentType()); return (T[]) ArrayConverter.INSTANCE.convert(a.getClass().getComponentType(), this);
} }
@Override @Override
@ -481,7 +483,7 @@ public class JSONArray implements JSON, JSONGetter<Integer>, List<Object>, Rando
* @return 实体类对象 * @return 实体类对象
*/ */
public Object toArray(final Class<?> arrayClass) { public Object toArray(final Class<?> arrayClass) {
return JSONConverter.toArray(this, arrayClass); return ArrayConverter.INSTANCE.convert(arrayClass, this);
} }
/** /**
@ -493,7 +495,7 @@ public class JSONArray implements JSON, JSONGetter<Integer>, List<Object>, Rando
* @since 3.0.8 * @since 3.0.8
*/ */
public <T> List<T> toList(final Class<T> elementType) { public <T> List<T> toList(final Class<T> elementType) {
return JSONConverter.toList(this, elementType); return Convert.toList(elementType, this);
} }
/** /**

View File

@ -49,7 +49,7 @@ public class JSONConfig implements Serializable {
* *
* @return JSONConfig * @return JSONConfig
*/ */
public static JSONConfig create() { public static JSONConfig of() {
return new JSONConfig(); return new JSONConfig();
} }

View File

@ -6,7 +6,6 @@ import cn.hutool.core.convert.Convert;
import cn.hutool.core.convert.ConvertException; import cn.hutool.core.convert.ConvertException;
import cn.hutool.core.convert.Converter; import cn.hutool.core.convert.Converter;
import cn.hutool.core.convert.ConverterRegistry; import cn.hutool.core.convert.ConverterRegistry;
import cn.hutool.core.convert.impl.ArrayConverter;
import cn.hutool.core.convert.impl.BeanConverter; import cn.hutool.core.convert.impl.BeanConverter;
import cn.hutool.core.reflect.ConstructorUtil; import cn.hutool.core.reflect.ConstructorUtil;
import cn.hutool.core.reflect.TypeUtil; import cn.hutool.core.reflect.TypeUtil;
@ -16,7 +15,6 @@ import cn.hutool.json.serialize.GlobalSerializeMapping;
import cn.hutool.json.serialize.JSONDeserializer; import cn.hutool.json.serialize.JSONDeserializer;
import java.lang.reflect.Type; import java.lang.reflect.Type;
import java.util.List;
/** /**
* JSON转换器 * JSON转换器
@ -41,29 +39,6 @@ public class JSONConverter implements Converter {
return JSONUtil.parse(value); return JSONUtil.parse(value);
} }
/**
* JSONArray转数组
*
* @param jsonArray JSONArray
* @param arrayClass 数组元素类型
* @return 数组对象
*/
protected static Object toArray(final JSONArray jsonArray, final Class<?> arrayClass) {
return ArrayConverter.INSTANCE.convert(arrayClass, jsonArray, null);
}
/**
* 将JSONArray转换为指定类型的对量列表
*
* @param <T> 元素类型
* @param jsonArray JSONArray
* @param elementType 对象元素类型
* @return 对象列表
*/
protected static <T> List<T> toList(final JSONArray jsonArray, final Class<T> elementType) {
return Convert.toList(elementType, jsonArray);
}
/** /**
* JSON递归转换<br> * JSON递归转换<br>
* 首先尝试JDK类型转换如果失败尝试JSON转Bean<br> * 首先尝试JDK类型转换如果失败尝试JSON转Bean<br>

View File

@ -46,7 +46,7 @@ public class JSONObject extends MapWrapper<String, Object> implements JSON, JSON
* 构造初始容量为 {@link #DEFAULT_CAPACITY}KEY有序 * 构造初始容量为 {@link #DEFAULT_CAPACITY}KEY有序
*/ */
public JSONObject() { public JSONObject() {
this(JSONConfig.create()); this(JSONConfig.of());
} }
/** /**
@ -67,8 +67,8 @@ public class JSONObject extends MapWrapper<String, Object> implements JSON, JSON
* @since 4.1.19 * @since 4.1.19
*/ */
public JSONObject(final int capacity, final JSONConfig config) { public JSONObject(final int capacity, final JSONConfig config) {
super(InternalJSONUtil.createRawMap(capacity, ObjUtil.defaultIfNull(config, JSONConfig.create()))); super(InternalJSONUtil.createRawMap(capacity, ObjUtil.defaultIfNull(config, JSONConfig.of())));
this.config = ObjUtil.defaultIfNull(config, JSONConfig.create()); this.config = ObjUtil.defaultIfNull(config, JSONConfig.of());
} }
/** /**
@ -84,7 +84,7 @@ public class JSONObject extends MapWrapper<String, Object> implements JSON, JSON
* @param source JavaBean或者Map对象或者String * @param source JavaBean或者Map对象或者String
*/ */
public JSONObject(final Object source) { public JSONObject(final Object source) {
this(source, JSONConfig.create().setIgnoreNullValue(InternalJSONUtil.defaultIgnoreNullValue(source))); this(source, JSONConfig.of().setIgnoreNullValue(InternalJSONUtil.defaultIgnoreNullValue(source)));
} }
/** /**

View File

@ -113,7 +113,7 @@ public class JSONUtil {
* @since 3.0.9 * @since 3.0.9
*/ */
public static JSONObject parseObj(final Object obj, final boolean ignoreNullValue) { public static JSONObject parseObj(final Object obj, final boolean ignoreNullValue) {
return new JSONObject(obj, JSONConfig.create().setIgnoreNullValue(ignoreNullValue)); return new JSONObject(obj, JSONConfig.of().setIgnoreNullValue(ignoreNullValue));
} }
/** /**
@ -148,7 +148,7 @@ public class JSONUtil {
* @since 3.2.3 * @since 3.2.3
*/ */
public static JSONArray parseArray(final Object arrayOrCollection, final boolean ignoreNullValue) { public static JSONArray parseArray(final Object arrayOrCollection, final boolean ignoreNullValue) {
return new JSONArray(arrayOrCollection, JSONConfig.create().setIgnoreNullValue(ignoreNullValue)); return new JSONArray(arrayOrCollection, JSONConfig.of().setIgnoreNullValue(ignoreNullValue));
} }
/** /**
@ -438,7 +438,7 @@ public class JSONUtil {
* @since 4.3.2 * @since 4.3.2
*/ */
public static <T> T toBean(final String jsonString, final Type beanType, final boolean ignoreError) { public static <T> T toBean(final String jsonString, final Type beanType, final boolean ignoreError) {
return parse(jsonString, JSONConfig.create().setIgnoreError(ignoreError)).toBean(beanType); return parse(jsonString, JSONConfig.of().setIgnoreError(ignoreError)).toBean(beanType);
} }
/** /**

View File

@ -21,7 +21,7 @@ public class Claims implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
// 时间使用秒级时间戳表示 // 时间使用秒级时间戳表示
private final JSONConfig CONFIG = JSONConfig.create().setDateFormat("#sss"); private final JSONConfig CONFIG = JSONConfig.of().setDateFormat("#sss");
private JSONObject claimJSON; private JSONObject claimJSON;

View File

@ -19,7 +19,7 @@ public class Issue1075Test {
@Test @Test
public void testToBeanIgnoreCase() { public void testToBeanIgnoreCase() {
// 在忽略大小写的情况下f2fac都匹配 // 在忽略大小写的情况下f2fac都匹配
final ObjA o2 = JSONUtil.parseObj(jsonStr, JSONConfig.create().setIgnoreCase(true)).toBean(ObjA.class); final ObjA o2 = JSONUtil.parseObj(jsonStr, JSONConfig.of().setIgnoreCase(true)).toBean(ObjA.class);
Assert.assertEquals("fac", o2.getFAC()); Assert.assertEquals("fac", o2.getFAC());
Assert.assertEquals("f2", o2.getF2()); Assert.assertEquals("f2", o2.getF2());

View File

@ -23,12 +23,12 @@ public class Issue2223Test {
map1.put("m1", m1); map1.put("m1", m1);
Assert.assertEquals("{\"m1\":{\"2022/0\":0,\"2022/1\":1,\"2022/2\":2,\"2022/3\":3,\"2022/4\":4}}", Assert.assertEquals("{\"m1\":{\"2022/0\":0,\"2022/1\":1,\"2022/2\":2,\"2022/3\":3,\"2022/4\":4}}",
JSONUtil.toJsonStr(map1, JSONConfig.create())); JSONUtil.toJsonStr(map1, JSONConfig.of()));
final BeanDemo beanDemo = new BeanDemo(); final BeanDemo beanDemo = new BeanDemo();
beanDemo.setMap1(map1); beanDemo.setMap1(map1);
Assert.assertEquals("{\"map1\":{\"m1\":{\"2022/0\":0,\"2022/1\":1,\"2022/2\":2,\"2022/3\":3,\"2022/4\":4}}}", Assert.assertEquals("{\"map1\":{\"m1\":{\"2022/0\":0,\"2022/1\":1,\"2022/2\":2,\"2022/3\":3,\"2022/4\":4}}}",
JSONUtil.toJsonStr(beanDemo, JSONConfig.create())); JSONUtil.toJsonStr(beanDemo, JSONConfig.of()));
} }
@Data @Data

View File

@ -12,7 +12,7 @@ public class IssueI4RBZ4Test {
public void sortTest(){ public void sortTest(){
final String jsonStr = "{\"id\":\"123\",\"array\":[1,2,3],\"outNum\":356,\"body\":{\"ava1\":\"20220108\",\"use\":1,\"ava2\":\"20230108\"},\"name\":\"John\"}"; final String jsonStr = "{\"id\":\"123\",\"array\":[1,2,3],\"outNum\":356,\"body\":{\"ava1\":\"20220108\",\"use\":1,\"ava2\":\"20230108\"},\"name\":\"John\"}";
final JSONObject jsonObject = JSONUtil.parseObj(jsonStr, JSONConfig.create().setNatureKeyComparator()); final JSONObject jsonObject = JSONUtil.parseObj(jsonStr, JSONConfig.of().setNatureKeyComparator());
Assert.assertEquals("{\"array\":[1,2,3],\"body\":{\"ava1\":\"20220108\",\"ava2\":\"20230108\",\"use\":1},\"id\":\"123\",\"name\":\"John\",\"outNum\":356}", jsonObject.toString()); Assert.assertEquals("{\"array\":[1,2,3],\"body\":{\"ava1\":\"20220108\",\"ava2\":\"20230108\",\"use\":1},\"id\":\"123\",\"name\":\"John\",\"outNum\":356}", jsonObject.toString());
} }
} }

View File

@ -10,7 +10,7 @@ public class IssueI50EGGTest {
@Test @Test
public void toBeanTest(){ public void toBeanTest(){
final String data = "{\"return_code\": 1, \"return_msg\": \"成功\", \"return_data\" : null}"; final String data = "{\"return_code\": 1, \"return_msg\": \"成功\", \"return_data\" : null}";
final ApiResult<?> apiResult = JSONUtil.toBean(data, JSONConfig.create().setIgnoreCase(true), ApiResult.class); final ApiResult<?> apiResult = JSONUtil.toBean(data, JSONConfig.of().setIgnoreCase(true), ApiResult.class);
Assert.assertEquals(1, apiResult.getReturn_code()); Assert.assertEquals(1, apiResult.getReturn_code());
} }

View File

@ -31,11 +31,11 @@ public class JSONArrayTest {
// JSONObject实现了Iterable接口可以转换为JSONArray // JSONObject实现了Iterable接口可以转换为JSONArray
final JSONObject jsonObject = new JSONObject(); final JSONObject jsonObject = new JSONObject();
JSONArray jsonArray = new JSONArray(jsonObject, JSONConfig.create()); JSONArray jsonArray = new JSONArray(jsonObject, JSONConfig.of());
Assert.assertEquals(new JSONArray(), jsonArray); Assert.assertEquals(new JSONArray(), jsonArray);
jsonObject.set("key1", "value1"); jsonObject.set("key1", "value1");
jsonArray = new JSONArray(jsonObject, JSONConfig.create()); jsonArray = new JSONArray(jsonObject, JSONConfig.of());
Assert.assertEquals(1, jsonArray.size()); Assert.assertEquals(1, jsonArray.size());
Assert.assertEquals("[{\"key1\":\"value1\"}]", jsonArray.toString()); Assert.assertEquals("[{\"key1\":\"value1\"}]", jsonArray.toString());
} }
@ -44,7 +44,7 @@ public class JSONArrayTest {
public void addNullTest(){ public void addNullTest(){
final List<String> aaa = ListUtil.view("aaa", null); final List<String> aaa = ListUtil.view("aaa", null);
final String jsonStr = JSONUtil.toJsonStr(JSONUtil.parse(aaa, final String jsonStr = JSONUtil.toJsonStr(JSONUtil.parse(aaa,
JSONConfig.create().setIgnoreNullValue(false))); JSONConfig.of().setIgnoreNullValue(false)));
Assert.assertEquals("[\"aaa\",null]", jsonStr); Assert.assertEquals("[\"aaa\",null]", jsonStr);
} }
@ -135,7 +135,7 @@ public class JSONArrayTest {
public void toDictListTest() { public void toDictListTest() {
final String jsonArr = "[{\"id\":111,\"name\":\"test1\"},{\"id\":112,\"name\":\"test2\"}]"; final String jsonArr = "[{\"id\":111,\"name\":\"test1\"},{\"id\":112,\"name\":\"test2\"}]";
final JSONArray array = JSONUtil.parseArray(jsonArr, JSONConfig.create().setIgnoreError(false)); final JSONArray array = JSONUtil.parseArray(jsonArr, JSONConfig.of().setIgnoreError(false));
final List<Dict> list = JSONUtil.toList(array, Dict.class); final List<Dict> list = JSONUtil.toList(array, Dict.class);
@ -273,7 +273,7 @@ public class JSONArrayTest {
@Test @Test
public void putNullTest(){ public void putNullTest(){
final JSONArray array = JSONUtil.createArray(JSONConfig.create().setIgnoreNullValue(false)); final JSONArray array = JSONUtil.createArray(JSONConfig.of().setIgnoreNullValue(false));
array.set(null); array.set(null);
Assert.assertEquals("[null]", array.toString()); Assert.assertEquals("[null]", array.toString());

View File

@ -199,7 +199,7 @@ public class JSONObjectTest {
@Test @Test
public void toBeanTest() { public void toBeanTest() {
final JSONObject subJson = JSONUtil.createObj().set("value1", "strValue1").set("value2", "234"); final JSONObject subJson = JSONUtil.createObj().set("value1", "strValue1").set("value2", "234");
final JSONObject json = JSONUtil.createObj().set("strValue", "strTest").set("intValue", 123) final JSONObject json = JSONUtil.createObj(JSONConfig.of().setIgnoreError(true)).set("strValue", "strTest").set("intValue", 123)
// 测试空字符串转对象 // 测试空字符串转对象
.set("doubleValue", "") .set("doubleValue", "")
.set("beanValue", subJson) .set("beanValue", subJson)
@ -453,7 +453,7 @@ public class JSONObjectTest {
@Test @Test
public void setDateFormatTest() { public void setDateFormatTest() {
final JSONConfig jsonConfig = JSONConfig.create(); final JSONConfig jsonConfig = JSONConfig.of();
jsonConfig.setDateFormat("yyyy-MM-dd HH:mm:ss"); jsonConfig.setDateFormat("yyyy-MM-dd HH:mm:ss");
final JSONObject json = new JSONObject(jsonConfig); final JSONObject json = new JSONObject(jsonConfig);
@ -465,7 +465,7 @@ public class JSONObjectTest {
@Test @Test
public void setDateFormatTest2() { public void setDateFormatTest2() {
final JSONConfig jsonConfig = JSONConfig.create(); final JSONConfig jsonConfig = JSONConfig.of();
jsonConfig.setDateFormat("yyyy#MM#dd"); jsonConfig.setDateFormat("yyyy#MM#dd");
final Date date = DateUtil.parse("2020-06-05 11:16:11"); final Date date = DateUtil.parse("2020-06-05 11:16:11");
@ -485,7 +485,7 @@ public class JSONObjectTest {
@Test @Test
public void setCustomDateFormatTest() { public void setCustomDateFormatTest() {
final JSONConfig jsonConfig = JSONConfig.create(); final JSONConfig jsonConfig = JSONConfig.of();
jsonConfig.setDateFormat("#sss"); jsonConfig.setDateFormat("#sss");
final Date date = DateUtil.parse("2020-06-05 11:16:11"); final Date date = DateUtil.parse("2020-06-05 11:16:11");
@ -599,7 +599,7 @@ public class JSONObjectTest {
@Test(expected = JSONException.class) @Test(expected = JSONException.class)
public void createJSONObjectTest() { public void createJSONObjectTest() {
// 集合类不支持转为JSONObject // 集合类不支持转为JSONObject
new JSONObject(new JSONArray(), JSONConfig.create()); new JSONObject(new JSONArray(), JSONConfig.of());
} }
@Test @Test
@ -646,7 +646,7 @@ public class JSONObjectTest {
@Test @Test
public void filterIncludeTest() { public void filterIncludeTest() {
final JSONObject json1 = JSONUtil.createObj(JSONConfig.create()) final JSONObject json1 = JSONUtil.createObj(JSONConfig.of())
.set("a", "value1") .set("a", "value1")
.set("b", "value2") .set("b", "value2")
.set("c", "value3") .set("c", "value3")
@ -658,7 +658,7 @@ public class JSONObjectTest {
@Test @Test
public void filterExcludeTest() { public void filterExcludeTest() {
final JSONObject json1 = JSONUtil.createObj(JSONConfig.create()) final JSONObject json1 = JSONUtil.createObj(JSONConfig.of())
.set("a", "value1") .set("a", "value1")
.set("b", "value2") .set("b", "value2")
.set("c", "value3") .set("c", "value3")
@ -670,7 +670,7 @@ public class JSONObjectTest {
@Test @Test
public void editTest() { public void editTest() {
final JSONObject json1 = JSONUtil.createObj(JSONConfig.create()) final JSONObject json1 = JSONUtil.createObj(JSONConfig.of())
.set("a", "value1") .set("a", "value1")
.set("b", "value2") .set("b", "value2")
.set("c", "value3") .set("c", "value3")
@ -690,7 +690,7 @@ public class JSONObjectTest {
@Test @Test
public void toUnderLineCaseTest() { public void toUnderLineCaseTest() {
final JSONObject json1 = JSONUtil.createObj(JSONConfig.create()) final JSONObject json1 = JSONUtil.createObj(JSONConfig.of())
.set("aKey", "value1") .set("aKey", "value1")
.set("bJob", "value2") .set("bJob", "value2")
.set("cGood", "value3") .set("cGood", "value3")
@ -705,7 +705,7 @@ public class JSONObjectTest {
@Test @Test
public void nullToEmptyTest() { public void nullToEmptyTest() {
final JSONObject json1 = JSONUtil.createObj(JSONConfig.create().setIgnoreNullValue(false)) final JSONObject json1 = JSONUtil.createObj(JSONConfig.of().setIgnoreNullValue(false))
.set("a", null) .set("a", null)
.set("b", "value2"); .set("b", "value2");

View File

@ -191,7 +191,7 @@ public class JSONUtilTest {
Assert.assertEquals("{\"test2\":12}", jsonObjectDefault.toString()); Assert.assertEquals("{\"test2\":12}", jsonObjectDefault.toString());
// 不去除多余的0 // 不去除多余的0
final JSONObject jsonObject = JSONUtil.createObj(JSONConfig.create().setStripTrailingZeros(false)) final JSONObject jsonObject = JSONUtil.createObj(JSONConfig.of().setStripTrailingZeros(false))
.set("test2", 12.00D); .set("test2", 12.00D);
Assert.assertEquals("{\"test2\":12.0}", jsonObject.toString()); Assert.assertEquals("{\"test2\":12.0}", jsonObject.toString());

View File

@ -20,7 +20,7 @@ public class TransientTest {
//noinspection MismatchedQueryAndUpdateOfCollection //noinspection MismatchedQueryAndUpdateOfCollection
final JSONObject jsonObject = new JSONObject(detailBill, final JSONObject jsonObject = new JSONObject(detailBill,
JSONConfig.create().setTransientSupport(false)); JSONConfig.of().setTransientSupport(false));
Assert.assertEquals("{\"id\":\"3243\",\"bizNo\":\"bizNo\"}", jsonObject.toString()); Assert.assertEquals("{\"id\":\"3243\",\"bizNo\":\"bizNo\"}", jsonObject.toString());
} }
@ -32,7 +32,7 @@ public class TransientTest {
//noinspection MismatchedQueryAndUpdateOfCollection //noinspection MismatchedQueryAndUpdateOfCollection
final JSONObject jsonObject = new JSONObject(detailBill, final JSONObject jsonObject = new JSONObject(detailBill,
JSONConfig.create().setTransientSupport(true)); JSONConfig.of().setTransientSupport(true));
Assert.assertEquals("{\"bizNo\":\"bizNo\"}", jsonObject.toString()); Assert.assertEquals("{\"bizNo\":\"bizNo\"}", jsonObject.toString());
} }
@ -43,7 +43,7 @@ public class TransientTest {
detailBill.setBizNo("bizNo"); detailBill.setBizNo("bizNo");
final JSONObject jsonObject = new JSONObject(detailBill, final JSONObject jsonObject = new JSONObject(detailBill,
JSONConfig.create().setTransientSupport(false)); JSONConfig.of().setTransientSupport(false));
final Bill bill = jsonObject.toBean(Bill.class); final Bill bill = jsonObject.toBean(Bill.class);
Assert.assertEquals("3243", bill.getId()); Assert.assertEquals("3243", bill.getId());
@ -57,7 +57,7 @@ public class TransientTest {
detailBill.setBizNo("bizNo"); detailBill.setBizNo("bizNo");
final JSONObject jsonObject = new JSONObject(detailBill, final JSONObject jsonObject = new JSONObject(detailBill,
JSONConfig.create().setTransientSupport(true)); JSONConfig.of().setTransientSupport(true));
final Bill bill = jsonObject.toBean(Bill.class); final Bill bill = jsonObject.toBean(Bill.class);
Assert.assertNull(bill.getId()); Assert.assertNull(bill.getId());