use of com.alibaba.fastjson.TypeReference in project fastjson by alibaba.
the class DefaultExtJSONParser_parseArray_2 method test_error_1.
public void test_error_1() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("[['1']]");
parser.config(Feature.AllowISO8601DateFormat, false);
Exception error = null;
try {
parser.parseArrayWithType(new TypeReference<Map<?, ?>>() {
}.getType());
} catch (Exception ex) {
error = ex;
}
Assert.assertNotNull(error);
}
use of com.alibaba.fastjson.TypeReference in project fastjson by alibaba.
the class DefaultExtJSONParser_parseArray method test_16.
public void test_16() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("[[1]]");
parser.config(Feature.AllowISO8601DateFormat, false);
Object[] array = parser.parseArray(new Type[] { new TypeReference<List<Integer>>() {
}.getType() });
Assert.assertEquals(new Integer(1), ((List<Integer>) (array[0])).get(0));
}
use of com.alibaba.fastjson.TypeReference in project fastjson by alibaba.
the class JSONReader_typeRef method test_array_1.
public void test_array_1() throws Exception {
JSONReader reader = new JSONReader(new StringReader("[[{\"id\":123}]]"));
reader.startArray();
List<VO> list = reader.readObject(new TypeReference<List<VO>>() {
}.getType());
Assert.assertEquals(123, list.get(0).getId());
reader.endArray();
reader.close();
}
use of com.alibaba.fastjson.TypeReference in project otter by alibaba.
the class AutoKeeperClusterServiceImpl method doToModel.
private AutoKeeperCluster doToModel(AutoKeeperClusterDO autoKeeperClusterDo) {
AutoKeeperCluster autoKeeperCluster = new AutoKeeperCluster();
autoKeeperCluster.setId(autoKeeperClusterDo.getId());
autoKeeperCluster.setClusterName(autoKeeperClusterDo.getClusterName());
autoKeeperCluster.setDescription(autoKeeperClusterDo.getDescription());
autoKeeperCluster.setServerList(JsonUtils.unmarshalFromString(autoKeeperClusterDo.getServerList(), new TypeReference<List<String>>() {
}));
autoKeeperCluster.setGmtCreate(autoKeeperClusterDo.getGmtCreate());
autoKeeperCluster.setGmtModified(autoKeeperClusterDo.getGmtModified());
return autoKeeperCluster;
}
use of com.alibaba.fastjson.TypeReference in project otter by alibaba.
the class DataColumnPairGroupServiceImpl method doToModel.
/*-------------------------------------------------------------*/
/**
* 用于DO对象转化为Model对象
*/
private ColumnGroup doToModel(DataColumnPairGroupDO dataColumnPairGroupDo) {
ColumnGroup columnGroup = new ColumnGroup();
columnGroup.setId(dataColumnPairGroupDo.getId());
List<ColumnPair> columnPairs = new ArrayList<ColumnPair>();
if (StringUtils.isNotBlank(dataColumnPairGroupDo.getColumnPairContent())) {
columnPairs = JsonUtils.unmarshalFromString(dataColumnPairGroupDo.getColumnPairContent(), new TypeReference<ArrayList<ColumnPair>>() {
});
}
columnGroup.setColumnPairs(columnPairs);
columnGroup.setDataMediaPairId(dataColumnPairGroupDo.getDataMediaPairId());
columnGroup.setGmtCreate(dataColumnPairGroupDo.getGmtCreate());
columnGroup.setGmtModified(dataColumnPairGroupDo.getGmtModified());
return columnGroup;
}
Aggregations