This commit is contained in:
Looly
2024-09-19 21:59:10 +08:00
parent 59c168a99c
commit 91d425ba63
7 changed files with 37 additions and 36 deletions

View File

@@ -19,6 +19,7 @@ package org.dromara.hutool.json;
import lombok.Data;
import org.dromara.hutool.core.collection.ListUtil;
import org.dromara.hutool.core.io.file.FileUtil;
import org.dromara.hutool.core.lang.Console;
import org.dromara.hutool.core.map.Dict;
import org.dromara.hutool.core.reflect.TypeReference;
import org.dromara.hutool.core.util.CharsetUtil;
@@ -74,14 +75,14 @@ public class JSONArrayTest {
array.set("value2");
array.set("value3");
assertEquals(array.get(0), "value1");
assertEquals(array.getObj(0), "value1");
}
@Test
public void parseTest() {
final String jsonStr = "[\"value1\", \"value2\", \"value3\"]";
final JSONArray array = JSONUtil.parseArray(jsonStr);
assertEquals(array.get(0), "value1");
assertEquals(array.getObj(0), "value1");
}
@Test
@@ -192,13 +193,14 @@ public class JSONArrayTest {
@Test
public void toListWithErrorTest() {
Assertions.assertThrows(JSONException.class, ()->{
final String json = "[['aaa',{'akey':'avalue','bkey':'bvalue'}]]";
final JSONArray ja = JSONUtil.parseArray(json);
// Assertions.assertThrows(JSONException.class, ()->{
// });
final String json = "[['aaa',{'akey':'avalue','bkey':'bvalue'}]]";
final JSONArray ja = JSONUtil.parseArray(json);
ja.toBean(new TypeReference<List<List<KeyBean>>>() {
});
});
final Object bean = ja.toBean(new TypeReference<List<List<KeyBean>>>() {});
Console.log(bean);
}
@Test

View File

@@ -17,11 +17,9 @@
package org.dromara.hutool.json.jwt;
import lombok.Data;
import org.dromara.hutool.core.collection.CollUtil;
import org.dromara.hutool.core.date.DatePattern;
import org.dromara.hutool.core.date.DateUtil;
import org.dromara.hutool.core.reflect.TypeReference;
import org.dromara.hutool.core.text.StrUtil;
import org.dromara.hutool.core.util.ByteUtil;
import org.dromara.hutool.json.jwt.signers.AlgorithmUtil;
import org.dromara.hutool.json.jwt.signers.JWTSigner;
@@ -163,9 +161,7 @@ public class JWTTest {
Assertions.assertEquals(bean, beanRes);
Assertions.assertEquals(numRes, num);
Assertions.assertEquals(username, strRes);
Assertions.assertEquals(
StrUtil.wrap(CollUtil.join(list, ","), "[", "]"),
listRes.toString());
Assertions.assertEquals(list, listRes);
final String formattedDate = DateUtil.format(date, "yyyy-MM-dd HH:mm:ss");
final String formattedRes = DateUtil.format(dateRes, "yyyy-MM-dd HH:mm:ss");