use of com.alibaba.fastjson.TypeReference in project fastjson by alibaba.
the class TypeUtilsTest_cast method test_cast_1.
public void test_cast_1() throws Exception {
ParameterizedType parameterizedType = (ParameterizedType) new TypeReference<List<?>>() {
}.getType();
Type type = parameterizedType.getActualTypeArguments()[0];
Assert.assertEquals(null, TypeUtils.cast("", type, null));
}
use of com.alibaba.fastjson.TypeReference in project fastjson by alibaba.
the class DefaultObjectDeserializerTest2 method test_1.
public void test_1() throws Exception {
String input = "{'map':{}}";
DefaultJSONParser parser = new DefaultJSONParser(input, ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);
SortedMap<String, SortedMap> map = JSON.parseObject(input, new TypeReference<SortedMap<String, SortedMap>>() {
}.getType());
Assert.assertEquals(TreeMap.class, map.get("map").getClass());
}
use of com.alibaba.fastjson.TypeReference in project fastjson by alibaba.
the class ArrayListStringDeserializerTest method test_string_error_not_eof.
public void test_string_error_not_eof() throws Exception {
JSONException ex = null;
try {
JSON.parseObject("[}", new TypeReference<List<String>>() {
}.getType(), 0, Feature.AllowSingleQuotes);
} catch (JSONException e) {
ex = e;
}
Assert.assertNotNull(ex);
}
use of com.alibaba.fastjson.TypeReference in project fastjson by alibaba.
the class JSONReader_typeRef method test_array.
public void test_array() throws Exception {
JSONReader reader = new JSONReader(new StringReader("[{\"id\":123}]"));
List<VO> list = reader.readObject(new TypeReference<List<VO>>() {
}.getType());
Assert.assertEquals(123, list.get(0).getId());
reader.close();
}
use of com.alibaba.fastjson.TypeReference in project atlas by alibaba.
the class BundleInfoUtils method getBundleInfoMap.
private static Map<String, BundleInfo> getBundleInfoMap(AppVariantContext appVariantContext) throws IOException {
File baseBunfleInfoFile = new File(appVariantContext.getScope().getGlobalScope().getProject().getProjectDir(), "bundleBaseInfoFile.json");
Map<String, BundleInfo> bundleFileMap = Maps.newHashMap();
if (null != baseBunfleInfoFile && baseBunfleInfoFile.exists() && baseBunfleInfoFile.canRead()) {
String bundleBaseInfo = FileUtils.readFileToString(baseBunfleInfoFile, "utf-8");
bundleFileMap = JSON.parseObject(bundleBaseInfo, new TypeReference<Map<String, BundleInfo>>() {
});
}
return bundleFileMap;
}
Aggregations