diff --git a/storage/src/main/java/com/zfoo/storage/convert/ArrayConverter.java b/storage/src/main/java/com/zfoo/storage/convert/ArrayConverter.java index 9ab110d7d..a97fc58db 100644 --- a/storage/src/main/java/com/zfoo/storage/convert/ArrayConverter.java +++ b/storage/src/main/java/com/zfoo/storage/convert/ArrayConverter.java @@ -46,10 +46,14 @@ public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor t return Array.newInstance(componentType, 0); } // 如果为json格式,则以json格式解析 - if (content.startsWith("[") || content.endsWith("]")) { - return componentType.isPrimitive() - ? JsonUtils.string2Object(content, targetType.getObjectType()) - : JsonUtils.string2Array(content, componentType); + if (content.startsWith("[") && content.endsWith("]")) { + try { + return componentType.isPrimitive() + ? JsonUtils.string2Object(content, targetType.getObjectType()) + : JsonUtils.string2Array(content, componentType); + + } catch (Exception e) { + } } return ConvertUtils.convertToArray(content, componentType); } diff --git a/storage/src/main/java/com/zfoo/storage/convert/ListConverter.java b/storage/src/main/java/com/zfoo/storage/convert/ListConverter.java index 7bb84744e..c04037da8 100644 --- a/storage/src/main/java/com/zfoo/storage/convert/ListConverter.java +++ b/storage/src/main/java/com/zfoo/storage/convert/ListConverter.java @@ -54,8 +54,11 @@ public Object convert(Object source, @NonNull TypeDescriptor sourceType, TypeDes } else { clazz = (Class) type; } - if (content.startsWith("[") || content.endsWith("]")) { - return Collections.unmodifiableList(JsonUtils.string2List(content, clazz)); + if (content.startsWith("[") && content.endsWith("]")) { + try { + return Collections.unmodifiableList(JsonUtils.string2List(content, clazz)); + } catch (Exception e) { + } } return ConvertUtils.convertToList(content, clazz); } diff --git a/storage/src/main/java/com/zfoo/storage/convert/SetConverter.java b/storage/src/main/java/com/zfoo/storage/convert/SetConverter.java index 133acb19a..36660a896 100644 --- a/storage/src/main/java/com/zfoo/storage/convert/SetConverter.java +++ b/storage/src/main/java/com/zfoo/storage/convert/SetConverter.java @@ -53,8 +53,11 @@ public Object convert(Object source, @NonNull TypeDescriptor sourceType, TypeDes } else { clazz = (Class) type; } - if (content.startsWith("[") || content.endsWith("]")) { - return Collections.unmodifiableSet(JsonUtils.string2Set(content, clazz)); + if (content.startsWith("[") && content.endsWith("]")) { + try { + return Collections.unmodifiableSet(JsonUtils.string2Set(content, clazz)); + } catch (Exception e) { + } } return ConvertUtils.convertToSet(content, clazz); }