FastJSON与其它的JSON解析jar包相比,FastJSON的速度要快上很多。如果大家需要下载FastJSON,可以翻我下面的链接:
阿里FastJson下载_进击的Coder*的博客-CSDN博客
List转化为JSONArray:
List<Table> tables = new ArrayList<>();
JSONArray jsonArray = JSONArray.parseArray(JSON.toJSONString(tables));
/**
* 以下为相关类
*/
public class Table {
private List<FieldType> fieldTypes;
}
public class FieldType {
private String field;
private DataType dataType;
private EntityType entityType;
}
public enum DataType {
INT("INT"),
FLOAT("FLOAT"),
STRING("STRING"),
DATE("DATE");
}
public enum EntityType {
PERSON("PERSON"),
DATE("DATE"),
TIME("TIME"),
LOCATION("LOCATION"),
ORGANIZATION("ORGANIZATION"),
MISC("MISC"),
COUNTRY("COUNTRY"),
MONEY("MONEY"),
NUMBER("NUMBER"),
ORDINAL("ORDINAL"),
PERCENT("PERCENT"),
DURATION("DURATION");
}