本文整理汇总了Java中com.alibaba.fastjson.parser.DefaultJSONParser.close方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultJSONParser.close方法的具体用法?Java DefaultJSONParser.close怎么用?Java DefaultJSONParser.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.alibaba.fastjson.parser.DefaultJSONParser
的用法示例。
在下文中一共展示了DefaultJSONParser.close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseObject
import com.alibaba.fastjson.parser.DefaultJSONParser; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public static <T> T parseObject(String input, Type clazz, int featureValues, Feature... features) {
if (input == null) {
return null;
}
for (Feature feature : features) {
featureValues = Feature.config(featureValues, feature, true);
}
DefaultJSONParser parser = new DefaultJSONParser(input, ParserConfig.getGlobalInstance(), featureValues);
T value = (T) parser.parseObject(clazz);
parser.handleResovleTask(value);
parser.close();
return (T) value;
}
示例2: parseArray
import com.alibaba.fastjson.parser.DefaultJSONParser; //导入方法依赖的package包/类
public static final List<Object> parseArray(String text, Type[] types) {
if (text == null) {
return null;
}
List<Object> list;
DefaultJSONParser parser = new DefaultJSONParser(text, ParserConfig.getGlobalInstance());
Object[] objectArray = parser.parseArray(types);
if (objectArray == null) {
list = null;
} else {
list = Arrays.asList(objectArray);
}
parser.handleResovleTask(list);
parser.close();
return list;
}
示例3: test_scanFloat
import com.alibaba.fastjson.parser.DefaultJSONParser; //导入方法依赖的package包/类
public void test_scanFloat() throws Exception {
StringBuffer buf = new StringBuffer();
buf.append('[');
for (int i = 0; i < 1024; ++i) {
if (i != 0) {
buf.append(',');
}
buf.append("{\"id\":" + i + ".0}");
}
buf.append(']');
Reader reader = new StringReader(buf.toString());
JSONReaderScanner scanner = new JSONReaderScanner(reader);
DefaultJSONParser parser = new DefaultJSONParser(scanner);
List<VO> array = parser.parseArray(VO.class);
for (int i = 0; i < array.size(); ++i) {
Assert.assertTrue((double) i == array.get(i).getId());
}
parser.close();
}
示例4: test_long
import com.alibaba.fastjson.parser.DefaultJSONParser; //导入方法依赖的package包/类
public void test_long() throws Exception {
char[] chars = "{\"value\":3L}".toCharArray();
DefaultJSONParser parser = new DefaultJSONParser(new JSONReaderScanner(chars, chars.length));
JSONObject json = parser.parseObject();
Assert.assertTrue(3L == ((Long) json.get("value")).longValue());
parser.close();
}
示例5: test_date_1
import com.alibaba.fastjson.parser.DefaultJSONParser; //导入方法依赖的package包/类
public void test_date_1() throws Exception {
int features = JSON.DEFAULT_PARSER_FEATURE;
features = Feature.config(features, Feature.AllowISO8601DateFormat, true);
DefaultJSONParser parser = new DefaultJSONParser("\"2011-01-09T13:49:53.254\"", ParserConfig.getGlobalInstance(), features);
java.sql.Date date = parser.parseObject(java.sql.Date.class);
Assert.assertEquals(new java.sql.Date(1294552193254L), date);
parser.close();
}
示例6: test_date_new_1
import com.alibaba.fastjson.parser.DefaultJSONParser; //导入方法依赖的package包/类
public void test_date_new_1() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("new Date(1294552193254)");
java.util.Date date = (java.util.Date) parser.parse();
Assert.assertEquals(new java.util.Date(1294552193254L), date);
parser.close();
}
示例7: test_date_2
import com.alibaba.fastjson.parser.DefaultJSONParser; //导入方法依赖的package包/类
public void test_date_2() throws Exception {
int features = JSON.DEFAULT_PARSER_FEATURE;
DefaultJSONParser parser = new DefaultJSONParser("new Date(1294552193254)", ParserConfig.getGlobalInstance(), features);
java.sql.Date date = parser.parseObject(java.sql.Date.class);
Assert.assertEquals(new java.sql.Date(1294552193254L), date);
parser.close();
}
示例8: test_true
import com.alibaba.fastjson.parser.DefaultJSONParser; //导入方法依赖的package包/类
public void test_true() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser(new JSONReaderScanner("{\"items\":[{}],\"value\":{}}"));
VO vo = parser.parseObject(VO.class);
Assert.assertNotNull(vo.getValue());
Assert.assertNotNull(vo.getItems());
Assert.assertEquals(1, vo.getItems().size());
Assert.assertNotNull(vo.getItems().get(0));
parser.close();
}
示例9: test_error_3
import com.alibaba.fastjson.parser.DefaultJSONParser; //导入方法依赖的package包/类
public void test_error_3() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("[] a");
parser.config(Feature.AllowISO8601DateFormat, false);
List list = new ArrayList();
Exception error = null;
try {
parser.parseArray(list);
parser.close();
} catch (Exception ex) {
error = ex;
}
Assert.assertNotNull(error);
}
示例10: parseObject
import com.alibaba.fastjson.parser.DefaultJSONParser; //导入方法依赖的package包/类
public static final <T> T parseObject(String input, Type clazz, int featureValues, Feature... features) {
if (input == null) {
return null;
}
for (Feature featrue : features) {
featureValues = Feature.config(featureValues, featrue, true);
}
DefaultJSONParser parser = new DefaultJSONParser(input, ParserConfig.getGlobalInstance(), featureValues);
T value = parser.parseObject(clazz);
parser.handleResovleTask(value);
parser.close();
return value;
}
示例11: test_date_4
import com.alibaba.fastjson.parser.DefaultJSONParser; //导入方法依赖的package包/类
public void test_date_4() throws Exception {
int features = JSON.DEFAULT_PARSER_FEATURE;
features = Feature.config(features, Feature.AllowISO8601DateFormat, true);
DefaultJSONParser parser = new DefaultJSONParser("\"2011-01-09\"", ParserConfig.getGlobalInstance(), features);
java.sql.Date date = parser.parseObject(java.sql.Date.class);
Assert.assertEquals(new java.sql.Date(1294502400000L), date);
parser.close();
}
示例12: f_test_date_0
import com.alibaba.fastjson.parser.DefaultJSONParser; //导入方法依赖的package包/类
public void f_test_date_0() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("1294552193254");
java.sql.Timestamp date = parser.parseObject(java.sql.Timestamp.class);
Assert.assertEquals(new java.sql.Timestamp(1294552193254L), date);
parser.close();
}
示例13: test_date_new
import com.alibaba.fastjson.parser.DefaultJSONParser; //导入方法依赖的package包/类
public void test_date_new() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("new Date(1294552193254)");
java.util.Date date = parser.parseObject(java.util.Date.class);
Assert.assertEquals(new java.util.Date(1294552193254L), date);
parser.close();
}
示例14: test
import com.alibaba.fastjson.parser.DefaultJSONParser; //导入方法依赖的package包/类
public void test() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("{\"date\":\"2012/04-01\"}", ParserConfig.getGlobalInstance(),
0);
parser.setDateFormat("yyyy/MM-dd");
VO vo = parser.parseObject(VO.class);
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM-dd", JSON.defaultLocale);
dateFormat.setTimeZone(JSON.defaultTimeZone);
Assert.assertEquals(dateFormat.parse("2012/04-01"), vo.getDate());
parser.close();
}
示例15: test_reader
import com.alibaba.fastjson.parser.DefaultJSONParser; //导入方法依赖的package包/类
public void test_reader() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser(new JSONReaderScanner("{\"date\":\"2012/04-01\"}", 0));
parser.setDateFormat("yyyy/MM-dd");
VO vo = parser.parseObject(VO.class);
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM-dd", JSON.defaultLocale);
dateFormat.setTimeZone(JSON.defaultTimeZone);
Assert.assertEquals(dateFormat.parse("2012/04-01"), vo.getDate());
parser.close();
}