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

@@ -145,7 +145,15 @@ public class ObjectMapper {
mapFromTokener(new JSONTokener((InputStream) source, jsonArray.getConfig()), jsonArray, filter);
} else if (source instanceof byte[]) {
// bytes按照JSON的二进制流对待
mapFromTokener(new JSONTokener(IoUtil.toStream((byte[]) source), jsonArray.getConfig()), jsonArray, filter);
try{
mapFromTokener(new JSONTokener(IoUtil.toStream((byte[]) source), jsonArray.getConfig()), jsonArray, filter);
} catch (final JSONException ignore){
// https://github.com/dromara/hutool/issues/2369
// 非标准的二进制流,则按照普通数组对待
for(final byte b : (byte[]) source){
jsonArray.add(b);
}
}
} else if (source instanceof JSONTokener) {
mapFromTokener((JSONTokener) source, jsonArray, filter);
} else {