mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
add test
This commit is contained in:
@@ -432,7 +432,7 @@ public class JSONObject implements JSON, JSONGetter<String>, Map<String, Object>
|
||||
InternalJSONUtil.testValidity(value);
|
||||
Object object = this.getObj(key);
|
||||
if (object == null) {
|
||||
this.set(key, value instanceof JSONArray ? new JSONArray(this.config).set(value) : value);
|
||||
this.set(key, (value instanceof JSONArray) ? value : new JSONArray(this.config).set(value));
|
||||
} else if (object instanceof JSONArray) {
|
||||
((JSONArray) object).set(value);
|
||||
} else {
|
||||
|
@@ -535,4 +535,10 @@ public class JSONObjectTest {
|
||||
final String s = JSONUtil.toJsonStr(map);
|
||||
Console.log(s);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void accumulateTest(){
|
||||
final JSONObject accumulate = JSONUtil.createObj().accumulate("key1", "value1");
|
||||
Assert.assertEquals("{\"key1\":[\"value1\"]}", accumulate.toString());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user