This commit is contained in:
Looly 2020-12-02 16:15:23 +08:00
parent 96d1708a71
commit f6289f118c
5 changed files with 16 additions and 8 deletions

View File

@ -4,7 +4,6 @@ import cn.hutool.core.annotation.Alias;
import cn.hutool.core.bean.copier.CopyOptions; import cn.hutool.core.bean.copier.CopyOptions;
import cn.hutool.core.bean.copier.ValueProvider; import cn.hutool.core.bean.copier.ValueProvider;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.lang.Console;
import cn.hutool.core.map.MapUtil; import cn.hutool.core.map.MapUtil;
import lombok.Data; import lombok.Data;
import lombok.Getter; import lombok.Getter;

View File

@ -378,7 +378,7 @@
<dependency> <dependency>
<groupId>com.googlecode.aviator</groupId> <groupId>com.googlecode.aviator</groupId>
<artifactId>aviator</artifactId> <artifactId>aviator</artifactId>
<version>5.1.4</version> <version>5.2.1</version>
<scope>compile</scope> <scope>compile</scope>
<optional>true</optional> <optional>true</optional>
</dependency> </dependency>

View File

@ -208,7 +208,7 @@ public class JSONArray implements JSON, JSONGetter<Integer>, List<Object>, Rando
} }
/** /**
* JSONArray转为以<code>separator</code>为分界符的字符串 * JSONArray转为以{@code separator}为分界符的字符串
* *
* @param separator 分界符 * @param separator 分界符
* @return a string. * @return a string.

View File

@ -1,6 +1,7 @@
package cn.hutool.json; package cn.hutool.json;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.convert.ConvertException; import cn.hutool.core.convert.ConvertException;
import cn.hutool.core.io.FileUtil; import cn.hutool.core.io.FileUtil;
import cn.hutool.core.lang.Console; import cn.hutool.core.lang.Console;
@ -33,6 +34,14 @@ public class JSONArrayTest {
new JSONArray(new JSONObject(), JSONConfig.create()); new JSONArray(new JSONObject(), JSONConfig.create());
} }
@Test
public void addNullTest(){
final List<String> aaa = ListUtil.of("aaa", null);
String jsonStr = JSONUtil.toJsonStr(JSONUtil.parse(aaa,
JSONConfig.create().setIgnoreNullValue(false)));
Assert.assertEquals("[\"aaa\",null]", jsonStr);
}
@Test @Test
public void addTest() { public void addTest() {
// 方法1 // 方法1
@ -96,7 +105,7 @@ public class JSONArrayTest {
List<Exam> list = array.toList(Exam.class); List<Exam> list = array.toList(Exam.class);
Assert.assertFalse(list.isEmpty()); Assert.assertFalse(list.isEmpty());
Assert.assertEquals(Exam.class, list.get(0).getClass()); Assert.assertSame(Exam.class, list.get(0).getClass());
} }
@Test @Test
@ -107,7 +116,7 @@ public class JSONArrayTest {
List<User> userList = JSONUtil.toList(array, User.class); List<User> userList = JSONUtil.toList(array, User.class);
Assert.assertFalse(userList.isEmpty()); Assert.assertFalse(userList.isEmpty());
Assert.assertEquals(User.class, userList.get(0).getClass()); Assert.assertSame(User.class, userList.get(0).getClass());
Assert.assertEquals(Integer.valueOf(111), userList.get(0).getId()); Assert.assertEquals(Integer.valueOf(111), userList.get(0).getId());
Assert.assertEquals(Integer.valueOf(112), userList.get(1).getId()); Assert.assertEquals(Integer.valueOf(112), userList.get(1).getId());
@ -125,7 +134,7 @@ public class JSONArrayTest {
List<Dict> list = JSONUtil.toList(array, Dict.class); List<Dict> list = JSONUtil.toList(array, Dict.class);
Assert.assertFalse(list.isEmpty()); Assert.assertFalse(list.isEmpty());
Assert.assertEquals(Dict.class, list.get(0).getClass()); Assert.assertSame(Dict.class, list.get(0).getClass());
Assert.assertEquals(Integer.valueOf(111), list.get(0).getInt("id")); Assert.assertEquals(Integer.valueOf(111), list.get(0).getInt("id"));
Assert.assertEquals(Integer.valueOf(112), list.get(1).getInt("id")); Assert.assertEquals(Integer.valueOf(112), list.get(1).getInt("id"));
@ -142,7 +151,7 @@ public class JSONArrayTest {
//noinspection SuspiciousToArrayCall //noinspection SuspiciousToArrayCall
Exam[] list = array.toArray(new Exam[0]); Exam[] list = array.toArray(new Exam[0]);
Assert.assertNotEquals(0, list.length); Assert.assertNotEquals(0, list.length);
Assert.assertEquals(Exam.class, list[0].getClass()); Assert.assertSame(Exam.class, list[0].getClass());
} }
/** /**

View File

@ -26,7 +26,7 @@
<dependency> <dependency>
<groupId>com.github.oshi</groupId> <groupId>com.github.oshi</groupId>
<artifactId>oshi-core</artifactId> <artifactId>oshi-core</artifactId>
<version>5.3.5</version> <version>5.3.6</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
</dependencies> </dependencies>