mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
json序列化时,增加允许多个相同的key配置
This commit is contained in:
@@ -234,4 +234,14 @@ public class JSONUtilTest {
|
||||
final String xmlStr = JSONUtil.toXmlStr(obj);
|
||||
Assert.assertEquals("<key1>v1</key1><key2>a</key2><key2>b</key2><key2>c</key2>", xmlStr);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDuplicateKey(){
|
||||
String str = "{id:123, name:\"张三\", name:\"李四\"}";
|
||||
|
||||
JSONObject jsonObject = JSONUtil.parseObj(str, JSONConfig.create().setIgnoreDuplicateKey(true));
|
||||
System.out.println(jsonObject.toString());
|
||||
|
||||
Assert.assertNotNull(jsonObject);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user