mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix json bug
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
package cn.hutool.core.convert.impl;
|
||||
|
||||
import cn.hutool.core.codec.Base64;
|
||||
import cn.hutool.core.collection.iter.IterUtil;
|
||||
import cn.hutool.core.convert.AbstractConverter;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.text.StrUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.ByteUtil;
|
||||
import cn.hutool.core.util.CharUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.core.text.StrUtil;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Array;
|
||||
@@ -124,6 +125,16 @@ public class ArrayConverter extends AbstractConverter<Object> {
|
||||
return convertArrayToArray(value.toString().toCharArray());
|
||||
}
|
||||
|
||||
//issue#2365
|
||||
// 字符串转bytes,首先判断是否为Base64,是则转换,否则按照默认getBytes方法。
|
||||
if(targetComponentType == byte.class){
|
||||
final String str = value.toString();
|
||||
if(Base64.isBase64(str)){
|
||||
return Base64.decode(value.toString());
|
||||
}
|
||||
return str.getBytes();
|
||||
}
|
||||
|
||||
// 单纯字符串情况下按照逗号分隔后劈开
|
||||
final String[] strings = StrUtil.splitToArray(value.toString(), CharUtil.COMMA);
|
||||
return convertArrayToArray(strings);
|
||||
|
Reference in New Issue
Block a user