本文整理汇总了Java中com.alibaba.fastjson.parser.DefaultJSONParser.config方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultJSONParser.config方法的具体用法?Java DefaultJSONParser.config怎么用?Java DefaultJSONParser.config使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.alibaba.fastjson.parser.DefaultJSONParser
的用法示例。
在下文中一共展示了DefaultJSONParser.config方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test_config
import com.alibaba.fastjson.parser.DefaultJSONParser; //导入方法依赖的package包/类
public void test_config() throws Exception {
new IOUtils();
DefaultJSONParser parser = new DefaultJSONParser("");
Assert.assertEquals(false, parser.isEnabled(Feature.AllowComment));
Assert.assertEquals(true, parser.isEnabled(Feature.AllowSingleQuotes));
Assert.assertEquals(true, parser.isEnabled(Feature.AllowUnQuotedFieldNames));
Assert.assertEquals(true, parser.isEnabled(Feature.AutoCloseSource));
Assert.assertEquals(true, parser.isEnabled(Feature.InternFieldNames));
parser.config(Feature.AllowComment, true);
Assert.assertEquals(true, parser.isEnabled(Feature.AllowComment));
parser.config(Feature.InternFieldNames, false);
Assert.assertEquals(false, parser.isEnabled(Feature.InternFieldNames));
}
示例2: test_error_1
import com.alibaba.fastjson.parser.DefaultJSONParser; //导入方法依赖的package包/类
public void test_error_1() throws Exception {
JSONException error = null;
try {
DefaultJSONParser parser = new DefaultJSONParser("{'a'3}");
parser.config(Feature.AllowSingleQuotes, true);
parser.parseObject(A.class);
} catch (JSONException e) {
error = e;
}
Assert.assertNotNull(error);
}
示例3: test_16
import com.alibaba.fastjson.parser.DefaultJSONParser; //导入方法依赖的package包/类
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));
}
示例4: test_double
import com.alibaba.fastjson.parser.DefaultJSONParser; //导入方法依赖的package包/类
public void test_double() {
DefaultJSONParser parser = new DefaultJSONParser("3.4");
parser.config(Feature.UseBigDecimal, false);
Assert.assertEquals("3.4", parser.getInput());
Assert.assertEquals(false, parser.isEnabled(Feature.UseBigDecimal));
Object result = parser.parse();
Assert.assertEquals(3.4D, result);
}
示例5: test_AllowUnQuotedFieldNames_0
import com.alibaba.fastjson.parser.DefaultJSONParser; //导入方法依赖的package包/类
public void test_AllowUnQuotedFieldNames_0() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("{a:3}");
parser.config(Feature.AllowUnQuotedFieldNames, true);
JSONObject json = (JSONObject) parser.parse();
Assert.assertEquals(1, json.size());
Assert.assertEquals(new Integer(3), (Integer) json.getInteger("a"));
}
示例6: test_1
import com.alibaba.fastjson.parser.DefaultJSONParser; //导入方法依赖的package包/类
public void test_1() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("{\"value\":3,\"id\":1}");
parser.config(Feature.AllowArbitraryCommas, false);
Entity entity = new Entity();
parser.parseObject(entity);
Assert.assertEquals(3, entity.getValue());
}
示例7: test_1
import com.alibaba.fastjson.parser.DefaultJSONParser; //导入方法依赖的package包/类
public void test_1() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("[1,2,3]");
parser.config(Feature.AllowArbitraryCommas, true);
List list = new ArrayList();
parser.parseArray(int.class, list);
Assert.assertEquals("[1, 2, 3]", list.toString());
}
示例8: test_error_3
import com.alibaba.fastjson.parser.DefaultJSONParser; //导入方法依赖的package包/类
public void test_error_3() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("[1,null }");
ArrayList list = new ArrayList();
parser.config(Feature.AllowISO8601DateFormat, false);
Exception error = null;
try {
parser.parseArray(String.class, list);
} catch (Exception ex) {
error = ex;
}
Assert.assertNotNull(error);
}
示例9: test_1
import com.alibaba.fastjson.parser.DefaultJSONParser; //导入方法依赖的package包/类
public void test_1() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("{v1:'3'}");
parser.config(Feature.AllowUnQuotedFieldNames, true);
parser.config(Feature.AllowSingleQuotes, true);
A a = parser.parseObject(A.class);
Assert.assertEquals(3, a.getV1());
}
示例10: test_date2
import com.alibaba.fastjson.parser.DefaultJSONParser; //导入方法依赖的package包/类
public void test_date2() {
String text = "{\"date\":\"xxxxx\"}";
char[] chars = text.toCharArray();
DefaultJSONParser parser = new DefaultJSONParser(chars, chars.length, ParserConfig.getGlobalInstance(), 0);
parser.config(Feature.AllowISO8601DateFormat, true);
JSONObject json = parser.parseObject();
Assert.assertEquals("xxxxx", json.get("date"));
}
示例11: test_4
import com.alibaba.fastjson.parser.DefaultJSONParser; //导入方法依赖的package包/类
public void test_4() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("{v5:'3'}");
parser.config(Feature.AllowUnQuotedFieldNames, true);
parser.config(Feature.AllowSingleQuotes, true);
A a = parser.parseObject(A.class);
Assert.assertEquals(3L, a.getV5().longValue());
}
示例12: test_3
import com.alibaba.fastjson.parser.DefaultJSONParser; //导入方法依赖的package包/类
public void test_3() throws Exception {
JSONException error = null;
try {
DefaultJSONParser parser = new DefaultJSONParser("{a 3}");
parser.config(Feature.AllowUnQuotedFieldNames, true);
parser.parse();
} catch (JSONException e) {
error = e;
}
Assert.assertNotNull(error);
}
示例13: test_0
import com.alibaba.fastjson.parser.DefaultJSONParser; //导入方法依赖的package包/类
public void test_0() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("{,,,,\"value\":3,\"id\":1}");
parser.config(Feature.AllowArbitraryCommas, true);
Entity entity = new Entity();
parser.parseObject(entity);
Assert.assertEquals(3, entity.getValue());
}
示例14: test_parseArray
import com.alibaba.fastjson.parser.DefaultJSONParser; //导入方法依赖的package包/类
public void test_parseArray() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("[1]");
parser.config(Feature.AllowArbitraryCommas, false);
List<String> list = new ArrayList<String>();
parser.parseArray(String.class, list);
Assert.assertEquals(1, list.size());
}
示例15: test_3
import com.alibaba.fastjson.parser.DefaultJSONParser; //导入方法依赖的package包/类
public void test_3() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("{o1:{}}");
parser.config(Feature.AllowUnQuotedFieldNames, true);
parser.config(Feature.AllowSingleQuotes, true);
A a = parser.parseObject(A.class);
Assert.assertEquals(true, a.getO1() != null);
}