in odps-console-dship/src/main/java/com/aliyun/odps/ship/common/RecordConverter.java [573:619]
private List<Object> transformArray(JsonArray arrayObj, ArrayTypeInfo typeInfo)
throws UnsupportedEncodingException, ParseException {
List<Object> newList = new ArrayList<>();
TypeInfo elementTypeInfo = typeInfo.getElementTypeInfo();
for (JsonElement element : arrayObj) {
switch (elementTypeInfo.getOdpsType()) {
case ARRAY:
JsonElement array = jsonParser.parse(element.getAsString());
// 当数据为null(字符串)时:
// 1. nullTag为null/NULL/""时, 会被jsonParser解析为JsonNull, 此时走isJsonNull()的逻辑
// 2. 当nullTag不为null/NULL/""时, 会被jsonParser解析为JsonPrimitive, 此时需要判断解析后的字符串与nullTag是否相等
// 以下同理
if (array.isJsonNull() || (array.isJsonPrimitive() && array.getAsString()
.equals(nullTag))) {
newList.add(null);
} else {
newList.add(transformArray(array.getAsJsonArray(), (ArrayTypeInfo) elementTypeInfo));
}
break;
case MAP:
JsonElement map = jsonParser.parse(element.getAsString());
if (map.isJsonNull() || (map.isJsonPrimitive() && map.getAsString().equals(nullTag))) {
newList.add(null);
} else {
newList.add(transformMap(map.getAsJsonObject(), (MapTypeInfo) elementTypeInfo));
}
break;
case STRUCT:
JsonElement struct = jsonParser.parse(element.getAsString());
if (struct.isJsonNull() || (struct.isJsonPrimitive() && struct.getAsString()
.equals(nullTag))) {
newList.add(null);
} else {
newList
.add(transformStruct(struct.getAsJsonObject(), (StructTypeInfo) elementTypeInfo));
}
break;
default:
newList.add(parseValue(elementTypeInfo, element.getAsString().getBytes(defaultCharset)));
break;
}
}
return newList;
}