This commit is contained in:
Looly
2022-06-10 22:53:30 +08:00
parent 90f9298370
commit a4db1e0e52
2 changed files with 28 additions and 1 deletions

View File

@@ -0,0 +1,19 @@
package cn.hutool.json;
import org.junit.Assert;
import org.junit.Test;
public class Issue2369Test {
@Test
public void toJsonStrTest(){
//https://github.com/dromara/hutool/issues/2369
// byte[]数组对于JSONArray来说即可能是一个JSON字符串的二进制流也可能是普通数组因此需要做双向兼容
final byte[] bytes = {10, 11};
final String s = JSONUtil.toJsonStr(bytes);
Assert.assertEquals("[10,11]", s);
final Object o = JSONUtil.toBean(s, byte[].class, false);
Assert.assertArrayEquals(bytes, (byte[])o);
}
}