本文整理汇总了Java中com.alibaba.fastjson.parser.Feature.config方法的典型用法代码示例。如果您正苦于以下问题:Java Feature.config方法的具体用法?Java Feature.config怎么用?Java Feature.config使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.alibaba.fastjson.parser.Feature
的用法示例。
在下文中一共展示了Feature.config方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseObject
import com.alibaba.fastjson.parser.Feature; //导入方法依赖的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: parseObject
import com.alibaba.fastjson.parser.Feature; //导入方法依赖的package包/类
public static final <T> T parseObject(String input, Type clazz, ParserConfig config, ParseProcess processor, int featureValues, Feature... features) {
if (input == null) {
return null;
}
for (Feature featrue : features) {
featureValues = Feature.config(featureValues, featrue, true);
}
DefaultJSONParser parser = new DefaultJSONParser(input, config, featureValues);
if (processor instanceof ExtraTypeProvider) {
parser.getExtraTypeProviders().add((ExtraTypeProvider) processor);
}
if (processor instanceof ExtraProcessor) {
parser.getExtraProcessors().add((ExtraProcessor) processor);
}
T value = parser.parseObject(clazz);
parser.handleResovleTask(value);
parser.close();
return value;
}
示例3: parse
import com.alibaba.fastjson.parser.Feature; //导入方法依赖的package包/类
public static Object parse(byte[] input, int off, int len, CharsetDecoder charsetDecoder, Feature... features) {
if (input == null || input.length == 0) {
return null;
}
int featureValues = DEFAULT_PARSER_FEATURE;
for (Feature feature : features) {
featureValues = Feature.config(featureValues, feature, true);
}
return parse(input, off, len, charsetDecoder, featureValues);
}
示例4: test_date_1
import com.alibaba.fastjson.parser.Feature; //导入方法依赖的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.util.Date date = parser.parseObject(java.util.Date.class);
Assert.assertEquals(new java.util.Date(1294552193254L), date);
parser.close();
}
示例5: test_date_4
import com.alibaba.fastjson.parser.Feature; //导入方法依赖的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.util.Date date = parser.parseObject(java.util.Date.class);
Assert.assertEquals(new java.util.Date(1294502400000L), date);
parser.close();
}
示例6: test_date_6
import com.alibaba.fastjson.parser.Feature; //导入方法依赖的package包/类
public void test_date_6() throws Exception {
int features = JSON.DEFAULT_PARSER_FEATURE;
features = Feature.config(features, Feature.AllowISO8601DateFormat, true);
java.util.Date date = JSON.parseObject("{d:\"2011-01-09T13:49:53\"}", Entity.class, Feature.AllowISO8601DateFormat).getD();
Assert.assertEquals(new java.util.Date(1294552193000L), date);
}
示例7: parse
import com.alibaba.fastjson.parser.Feature; //导入方法依赖的package包/类
public static final Object parse(byte[] input, int off, int len, CharsetDecoder charsetDecoder, Feature... features) {
if (input == null || input.length == 0) {
return null;
}
int featureValues = DEFAULT_PARSER_FEATURE;
for (Feature featrue : features) {
featureValues = Feature.config(featureValues, featrue, true);
}
return parse(input, off, len, charsetDecoder, featureValues);
}
示例8: test_date_1
import com.alibaba.fastjson.parser.Feature; //导入方法依赖的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();
}
示例9: test_date_3
import com.alibaba.fastjson.parser.Feature; //导入方法依赖的package包/类
public void test_date_3() throws Exception {
int features = JSON.DEFAULT_PARSER_FEATURE;
features = Feature.config(features, Feature.AllowISO8601DateFormat, true);
DefaultJSONParser parser = new DefaultJSONParser("\"2011-01-09T13:49:53\"", ParserConfig.getGlobalInstance(), features);
java.sql.Date date = parser.parseObject(java.sql.Date.class);
Assert.assertEquals(new java.sql.Date(1294552193000L), date);
parser.close();
}
示例10: test_date_4
import com.alibaba.fastjson.parser.Feature; //导入方法依赖的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();
}
示例11: parseObject
import com.alibaba.fastjson.parser.Feature; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public static final <T> T parseObject(String input, Type clazz, ParserConfig config, ParseProcess processor,
int featureValues, Feature... features) {
if (input == null) {
return null;
}
for (Feature featrue : features) {
featureValues = Feature.config(featureValues, featrue, true);
}
DefaultJSONParser parser = new DefaultJSONParser(input, config, featureValues);
if (processor instanceof ExtraTypeProvider) {
parser.getExtraTypeProviders().add((ExtraTypeProvider) processor);
}
if (processor instanceof ExtraProcessor) {
parser.getExtraProcessors().add((ExtraProcessor) processor);
}
T value = (T) parser.parseObject(clazz);
parser.handleResovleTask(value);
parser.close();
return (T) value;
}
示例12: test_date_3
import com.alibaba.fastjson.parser.Feature; //导入方法依赖的package包/类
public void test_date_3() throws Exception {
int features = JSON.DEFAULT_PARSER_FEATURE;
features = Feature.config(features, Feature.AllowISO8601DateFormat, true);
DefaultJSONParser parser = new DefaultJSONParser("\"2011-01-09T13:49:53\"", ParserConfig.getGlobalInstance(), features);
java.sql.Timestamp date = parser.parseObject(java.sql.Timestamp.class);
Assert.assertEquals(new java.sql.Timestamp(1294552193000L), date);
parser.close();
}
示例13: test_date_4
import com.alibaba.fastjson.parser.Feature; //导入方法依赖的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.Timestamp date = parser.parseObject(java.sql.Timestamp.class);
Assert.assertEquals(new java.sql.Timestamp(1294502400000L), date);
parser.close();
}
示例14: parse
import com.alibaba.fastjson.parser.Feature; //导入方法依赖的package包/类
public static final Object parse(byte[] input, int off, int len, CharsetDecoder charsetDecoder, Feature... features) {
if (input == null || input.length == 0) {
return null;
}
int featureValues = DEFAULT_PARSER_FEATURE;
for (Feature featrue : features) {
featureValues = Feature.config(featureValues, featrue, true);
}
return parse(input, off, len, charsetDecoder, featureValues);
}
示例15: test_6
import com.alibaba.fastjson.parser.Feature; //导入方法依赖的package包/类
public void test_6() throws Exception {
int features = JSON.DEFAULT_PARSER_FEATURE;
features = Feature.config(features, Feature.AllowSingleQuotes, true);
Assert.assertEquals(true, Feature.isEnabled(features, Feature.AllowSingleQuotes));
DefaultJSONParser parser = new DefaultJSONParser("'abc'", ParserConfig.getGlobalInstance(), features);
Assert.assertEquals("abc", parser.parse());
}