mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
fix test
This commit is contained in:
parent
917f6eeead
commit
1e9645c2e8
@ -145,7 +145,7 @@ public class ObjectMapper {
|
|||||||
mapFromTokener(new JSONTokener((InputStream) source, jsonArray.getConfig()), jsonArray, filter);
|
mapFromTokener(new JSONTokener((InputStream) source, jsonArray.getConfig()), jsonArray, filter);
|
||||||
} else if (source instanceof byte[]) {
|
} else if (source instanceof byte[]) {
|
||||||
final byte[] bytesSource = (byte[]) source;
|
final byte[] bytesSource = (byte[]) source;
|
||||||
if('[' == bytesSource[0]){
|
if ('[' == bytesSource[0] && ']' == bytesSource[bytesSource.length - 1]) {
|
||||||
mapFromTokener(new JSONTokener(IoUtil.toStream(bytesSource), jsonArray.getConfig()), jsonArray, filter);
|
mapFromTokener(new JSONTokener(IoUtil.toStream(bytesSource), jsonArray.getConfig()), jsonArray, filter);
|
||||||
} else {
|
} else {
|
||||||
// https://github.com/dromara/hutool/issues/2369
|
// https://github.com/dromara/hutool/issues/2369
|
||||||
|
@ -16,7 +16,7 @@ public class IssueI59LW4Test {
|
|||||||
@Test
|
@Test
|
||||||
public void bytesInJSONArrayTest(){
|
public void bytesInJSONArrayTest(){
|
||||||
final JSONArray jsonArray = JSONUtil.createArray().set(new byte[]{1});
|
final JSONArray jsonArray = JSONUtil.createArray().set(new byte[]{1});
|
||||||
Assert.assertEquals("[\"AQ==\"]", jsonArray.toString());
|
Assert.assertEquals("[[1]]", jsonArray.toString());
|
||||||
|
|
||||||
final byte[] bytes = jsonArray.getBytes(0);
|
final byte[] bytes = jsonArray.getBytes(0);
|
||||||
Assert.assertArrayEquals(new byte[]{1}, bytes);
|
Assert.assertArrayEquals(new byte[]{1}, bytes);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user