mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
fix add bug
This commit is contained in:
parent
fb87346d8a
commit
6002a1476f
@ -21,6 +21,7 @@
|
|||||||
* 【json 】 修复JSONGetter.getJSONArray判断null的问题(issue#I4C15H@Gitee)
|
* 【json 】 修复JSONGetter.getJSONArray判断null的问题(issue#I4C15H@Gitee)
|
||||||
* 【db 】 修复Condition没占位符的情况下sql没引号问题(issue#1846@Github)
|
* 【db 】 修复Condition没占位符的情况下sql没引号问题(issue#1846@Github)
|
||||||
* 【cache 】 修复FIFOCache中remove回调无效问题(pr#1856@Github)
|
* 【cache 】 修复FIFOCache中remove回调无效问题(pr#1856@Github)
|
||||||
|
* 【json 】 修复JSONArray.set中,index为0报错问题(issue#1858@Github)
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -449,7 +449,7 @@ public class JSONArray implements JSON, JSONGetter<Integer>, List<Object>, Rando
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Object set(int index, Object element) {
|
public Object set(int index, Object element) {
|
||||||
if(index > size()){
|
if(index >= size()){
|
||||||
add(index, element);
|
add(index, element);
|
||||||
}
|
}
|
||||||
return this.rawList.set(index, JSONUtil.wrap(element, this.config));
|
return this.rawList.set(index, JSONUtil.wrap(element, this.config));
|
||||||
|
@ -217,6 +217,15 @@ public class JSONArrayTest {
|
|||||||
Assert.assertEquals(4, jsonArray.size());
|
Assert.assertEquals(4, jsonArray.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://github.com/dromara/hutool/issues/1858
|
||||||
|
@Test
|
||||||
|
public void putTest2(){
|
||||||
|
final JSONArray jsonArray = new JSONArray();
|
||||||
|
jsonArray.put(0, 1);
|
||||||
|
Assert.assertEquals(1, jsonArray.size());
|
||||||
|
Assert.assertEquals(1, jsonArray.get(0));
|
||||||
|
}
|
||||||
|
|
||||||
private static Map<String, String> buildMap(String id, String parentId, String name) {
|
private static Map<String, String> buildMap(String id, String parentId, String name) {
|
||||||
Map<String, String> map = new HashMap<>();
|
Map<String, String> map = new HashMap<>();
|
||||||
map.put("id", id);
|
map.put("id", id);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user