1
报错信息:
java.lang.UnsupportedOperationException
at com.alibaba.fastjson.JSONPath.getArrayItem(JSONPath.java:3189)
at com.alibaba.fastjson.JSONPath$ArrayAccessSegment.eval(JSONPath.java:2324)
at com.alibaba.fastjson.JSONPath.eval(JSONPath.java:76)
at com.alibaba.fastjson.JSONPath.eval(JSONPath.java:455)
at com.alibaba.fastjson.parser.DefaultJSONParser.handleResovleTask(DefaultJSONParser.java:1561)
at com.alibaba.fastjson.JSON.parseObject(JSON.java:380)
at com.alibaba.fastjson.JSON.parseObject(JSON.java:282)
at com.alibaba.fastjson.JSON.parseObject(JSON.java:555)
at tests.PartitionIT.testIt(PartitionIT.java:325)
TestCase:
@Test
public void testIt() {
String str = "{\"success\":true,\"message\":null,\"data\":[{\"tblId\":78,\"partId\":104,\"values\":[\"p001\",\"q001\"],\"dbName\":\"db001\",\"tableName\":\"tbl001\",\"createTime\":1582293531,\"lastAccessTime\":1,\"sd\":{\"sdId\":182,\"cdId\":181,\"cols\":[{\"name\":\"col1\",\"type\":\"string\",\"comment\":null},{\"name\":\"col2\",\"type\":\"int\",\"comment\":\"col2\"},{\"name\":\"col3\",\"type\":\"boolean\",\"comment\":null}],\"location\":\"oss://temp/jianghu/db001/tbl001\",\"inputFormat\":\"org.apache.hadoop.hive.ql.io.parquet.MapredParquetInputFormat\",\"outputFormat\":\"org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormat\",\"compressed\":true,\"numBuckets\":2,\"serdeInfo\":{\"serdeId\":182,\"name\":null,\"serializationLib\":\"org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe\",\"parameters\":{\"field.delim\":\"\\t\",\"serialization.format\":\"\\t\"}},\"bucketCols\":[\"col1\"],\"sortCols\":[{\"col\":\"col1\",\"order\":0}],\"parameters\":{},\"skewedInfo\":{\"skewedColNames\":[\"col1\",\"col3\"],\"skewedColValues\":[[\"2\",\"1\"],[\"3\",\"2\"]],\"skewedColValueLocationMaps\":{}},\"storedAsSubDirectories\":false},\"parameters\":{\"totalSize\":\"0\",\"numRows\":\"-1\",\"rawDataSize\":\"-1\",\"COLUMN_STATS_ACCURATE\":\"false\",\"numFiles\":\"0\",\"transient_lastDdlTime\":\"1582293531\"},\"parametersSize\":6},{\"tblId\":78,\"partId\":105,\"values\":[\"p001\",\"q002\"],\"dbName\":\"db001\",\"tableName\":\"tbl001\",\"createTime\":1582293531,\"lastAccessTime\":1,\"sd\":{\"sdId\":183,\"cdId\":181,\"cols\":[{\"name\":\"col1\",\"type\":\"string\",\"comment\":null},{\"name\":\"col2\",\"type\":\"int\",\"comment\":\"col2\"},{\"name\":\"col3\",\"type\":\"boolean\",\"comment\":null}],\"location\":\"oss://temp/jianghu/db001/tbl001\",\"inputFormat\":\"org.apache.hadoop.hive.ql.io.parquet.MapredParquetInputFormat\",\"outputFormat\":\"org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormat\",\"compressed\":true,\"numBuckets\":2,\"serdeInfo\":{\"serdeId\":183,\"name\":null,\"serializationLib\":\"org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe\",\"parameters\":{\"field.delim\":\"\\t\",\"serialization.format\":\"\\t\"}},\"bucketCols\":[\"col1\"],\"sortCols\":[{\"col\":\"col1\",\"order\":0}],\"parameters\":{},\"skewedInfo\":{\"skewedColNames\":[\"col1\",\"col3\"],\"skewedColValues\":[[\"2\",\"1\"],[\"3\",\"2\"]],\"skewedColValueLocationMaps\":{}},\"storedAsSubDirectories\":false},\"parameters\":{\"totalSize\":\"0\",\"numRows\":\"-1\",\"rawDataSize\":\"-1\",\"COLUMN_STATS_ACCURATE\":\"false\",\"numFiles\":\"0\",\"transient_lastDdlTime\":\"1582293531\",\"$ref\":\"$[0].parameters\"},\"parametersSize\":7},{\"tblId\":78,\"partId\":106,\"values\":[\"p002\",\"q002\"],\"dbName\":\"db001\",\"tableName\":\"tbl001\",\"createTime\":1582293531,\"lastAccessTime\":1,\"sd\":{\"sdId\":184,\"cdId\":181,\"cols\":[{\"name\":\"col1\",\"type\":\"string\",\"comment\":null},{\"name\":\"col2\",\"type\":\"int\",\"comment\":\"col2\"},{\"name\":\"col3\",\"type\":\"boolean\",\"comment\":null}],\"location\":\"oss://temp/jianghu/db001/tbl001\",\"inputFormat\":\"org.apache.hadoop.hive.ql.io.parquet.MapredParquetInputFormat\",\"outputFormat\":\"org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormat\",\"compressed\":true,\"numBuckets\":2,\"serdeInfo\":{\"serdeId\":184,\"name\":null,\"serializationLib\":\"org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe\",\"parameters\":{\"field.delim\":\"\\t\",\"serialization.format\":\"\\t\"}},\"bucketCols\":[\"col1\"],\"sortCols\":[{\"col\":\"col1\",\"order\":0}],\"parameters\":{},\"skewedInfo\":{\"skewedColNames\":[\"col1\",\"col3\"],\"skewedColValues\":[[\"2\",\"1\"],[\"3\",\"2\"]],\"skewedColValueLocationMaps\":{}},\"storedAsSubDirectories\":false},\"parameters\":{\"totalSize\":\"0\",\"numRows\":\"-1\",\"rawDataSize\":\"-1\",\"COLUMN_STATS_ACCURATE\":\"false\",\"numFiles\":\"0\",\"transient_lastDdlTime\":\"1582293531\",\"$ref\":\"$[0].parameters\"},\"parametersSize\":7}]}";
ResultData obj = JSONObject.parseObject(str, ResultData.class);
System.out.println(obj);
}
相关类:
public class ResultData
{
private boolean success;
private String message;
private Object data;
}