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,12 +145,12 @@ public class ObjectMapper {
|
||||
mapFromTokener(new JSONTokener((InputStream) source, jsonArray.getConfig()), jsonArray, filter);
|
||||
} else if (source instanceof byte[]) {
|
||||
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);
|
||||
}else{
|
||||
} else {
|
||||
// https://github.com/dromara/hutool/issues/2369
|
||||
// 非标准的二进制流,则按照普通数组对待
|
||||
for(final byte b : bytesSource){
|
||||
for (final byte b : bytesSource) {
|
||||
jsonArray.add(b);
|
||||
}
|
||||
}
|
||||
@ -258,7 +258,7 @@ public class ObjectMapper {
|
||||
*/
|
||||
private static void mapFromBean(final Object bean, final JSONObject jsonObject, final Filter<MutableEntry<String, Object>> filter) {
|
||||
final CopyOptions copyOptions = InternalJSONUtil.toCopyOptions(jsonObject.getConfig());
|
||||
if(null != filter){
|
||||
if (null != filter) {
|
||||
copyOptions.setFieldEditor((entry -> filter.accept(entry) ? entry : null));
|
||||
}
|
||||
BeanUtil.beanToMap(bean, jsonObject, copyOptions);
|
||||
|
@ -16,7 +16,7 @@ public class IssueI59LW4Test {
|
||||
@Test
|
||||
public void bytesInJSONArrayTest(){
|
||||
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);
|
||||
Assert.assertArrayEquals(new byte[]{1}, bytes);
|
||||
|
Loading…
x
Reference in New Issue
Block a user