当前位置: 首页>>代码示例>>Java>>正文


Java ParserConfig.getGlobalInstance方法代码示例

本文整理汇总了Java中com.alibaba.fastjson.parser.ParserConfig.getGlobalInstance方法的典型用法代码示例。如果您正苦于以下问题:Java ParserConfig.getGlobalInstance方法的具体用法?Java ParserConfig.getGlobalInstance怎么用?Java ParserConfig.getGlobalInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.alibaba.fastjson.parser.ParserConfig的用法示例。


在下文中一共展示了ParserConfig.getGlobalInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parseObject

import com.alibaba.fastjson.parser.ParserConfig; //导入方法依赖的package包/类
public static final <T> T parseObject(String input, Type clazz, Feature... features) {
    if (input == null) {
        return null;
    }

    int featureValues = 0;
    for (Feature feature : features) {
        featureValues = Feature.config(featureValues, feature, true);
    }

    DefaultJSONParser parser = new DefaultJSONParser(input, ParserConfig.getGlobalInstance(), featureValues);
    T value = (T) parser.parseObject(clazz);

    if (clazz != JSONArray.class) {
        parser.close();
    }

    return (T) value;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:ArrayListStringDeserializerTest.java

示例2: parseObject

import com.alibaba.fastjson.parser.ParserConfig; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
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 = (T) parser.parseObject(clazz);

    parser.handleResovleTask(value);

    parser.close();

    return (T) value;
}
 
开发者ID:uavorg,项目名称:uavstack,代码行数:20,代码来源:JSON.java

示例3: toJavaList

import com.alibaba.fastjson.parser.ParserConfig; //导入方法依赖的package包/类
/**
 * @since  1.2.23
 */
public <T> List<T> toJavaList(Class<T> clazz) {
    List<T> list = new ArrayList<T>(this.size());

    ParserConfig config = ParserConfig.getGlobalInstance();

    for (Object item : this) {
        T classItem = (T) TypeUtils.cast(item, clazz, config);
        list.add(classItem);
    }

    return list;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:16,代码来源:JSONArray.java

示例4: test_error_1

import com.alibaba.fastjson.parser.ParserConfig; //导入方法依赖的package包/类
public void test_error_1() {
    String text = "{\"obj\":{}]}";
    char[] chars = text.toCharArray();
    DefaultJSONParser parser = new DefaultJSONParser(chars, chars.length, ParserConfig.getGlobalInstance(), 0);

    JSONException error = null;
    try {
        parser.parseObject();
    } catch (JSONException ex) {
        error = ex;
    }
    Assert.assertNotNull(error);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:14,代码来源:DefaultJSONParserTest_error.java

示例5: test_error_3

import com.alibaba.fastjson.parser.ParserConfig; //导入方法依赖的package包/类
public void test_error_3() {
    String text = "{\"obj\":true]}";
    char[] chars = text.toCharArray();
    DefaultJSONParser parser = new DefaultJSONParser(chars, chars.length, ParserConfig.getGlobalInstance(), 0);

    JSONException error = null;
    try {
        parser.parseObject();
    } catch (JSONException ex) {
        error = ex;
    }
    Assert.assertNotNull(error);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:14,代码来源:DefaultJSONParserTest_error.java

示例6: parseObject

import com.alibaba.fastjson.parser.ParserConfig; //导入方法依赖的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;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:14,代码来源:JSON.java

示例7: test_date_1

import com.alibaba.fastjson.parser.ParserConfig; //导入方法依赖的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.Timestamp date = parser.parseObject(java.sql.Timestamp.class);

    Assert.assertEquals(new java.sql.Timestamp(1294552193254L), date);
    parser.close();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:11,代码来源:DateParserTest_sql_timestamp.java

示例8: test_date

import com.alibaba.fastjson.parser.ParserConfig; //导入方法依赖的package包/类
public void test_date() {
    String text = "{\"date\":\"2011-01-09T13:49:53.254\"}";
    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(new Date(1294552193254L), json.get("date"));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:9,代码来源:DefaultJSONParserTest_date.java

示例9: parse

import com.alibaba.fastjson.parser.ParserConfig; //导入方法依赖的package包/类
public static final Object parse(byte[] input, int off, int len, CharsetDecoder charsetDecoder, int features) {
    charsetDecoder.reset();
    char[] chars = ThreadLocalCache.getChars((int) (((double) len) * ((double) charsetDecoder.maxCharsPerByte())));
    ByteBuffer byteBuf = ByteBuffer.wrap(input, off, len);
    CharBuffer charBuf = CharBuffer.wrap(chars);
    IOUtils.decode(charsetDecoder, byteBuf, charBuf);
    DefaultJSONParser parser = new DefaultJSONParser(chars, charBuf.position(), ParserConfig.getGlobalInstance(), features);
    Object value = parser.parse();
    parser.handleResovleTask(value);
    parser.close();
    return value;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:13,代码来源:JSON.java

示例10: test_date3

import com.alibaba.fastjson.parser.ParserConfig; //导入方法依赖的package包/类
public void test_date3() {
    String text = "{\"1234567890abcdefghijklmnopqrst1234567890abcdefghijklmnopqrst1234567890abcdefghijklmnopqrst\\t\":\"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("1234567890abcdefghijklmnopqrst1234567890abcdefghijklmnopqrst1234567890abcdefghijklmnopqrst\t"));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:9,代码来源:DefaultJSONParserTest_date.java

示例11: test_date_2

import com.alibaba.fastjson.parser.ParserConfig; //导入方法依赖的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.Timestamp date = parser.parseObject(java.sql.Timestamp.class);

    Assert.assertEquals(new java.sql.Timestamp(1294552193254L), date);
    parser.close();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:10,代码来源:DateParserTest_sql_timestamp.java

示例12: test_null

import com.alibaba.fastjson.parser.ParserConfig; //导入方法依赖的package包/类
public void test_null() throws Exception {
    String input = "null";
    DefaultJSONParser parser = new DefaultJSONParser(input, ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);

    MiscCodec deser = new MiscCodec();

    Assert.assertNull(deser.deserialze(parser, null, null));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:9,代码来源:LocaleTest.java

示例13: test_1

import com.alibaba.fastjson.parser.ParserConfig; //导入方法依赖的package包/类
public void test_1() throws Exception {
    String input = "{,,,\"value\":null,\"id\":123,,,,}";
    int featureValues = 0;
    featureValues |= Feature.AllowArbitraryCommas.getMask();
    featureValues |= Feature.IgnoreNotMatch.getMask();
    DefaultJSONParser parser = new DefaultJSONParser(input, ParserConfig.getGlobalInstance(), featureValues);
    
    Entity object = new Entity();
    parser.parseObject(object);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:11,代码来源:FieldDeserializerTest2.java

示例14: test_error_2

import com.alibaba.fastjson.parser.ParserConfig; //导入方法依赖的package包/类
public void test_error_2() throws Exception {
    Exception error = null;
    try {
        String input = "{,,\"value\":null}";
        int featureValues = 0;
        DefaultJSONParser parser = new DefaultJSONParser(input, ParserConfig.getGlobalInstance(),
                                                               featureValues);

        Entity object = new Entity();
        parser.parseObject(object);
    } catch (JSONException ex) {
        error = ex;
    }
    Assert.assertNotNull(error);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:16,代码来源:FieldDeserializerTest3.java

示例15: test_bigdecimal

import com.alibaba.fastjson.parser.ParserConfig; //导入方法依赖的package包/类
public void test_bigdecimal() throws Exception {
    Assert.assertEquals(0, JSON.parseObject("0", Double.class).intValue());
    Assert.assertEquals(0, JSON.parseObject("0.0", Double.class).intValue());
    Assert.assertEquals(0, JSON.parseObject("'0'", Double.class).intValue());
    Assert.assertEquals(0, JSON.parseObject("'0'", double.class).intValue());
    Assert.assertEquals(null, JSON.parseObject("null", Double.class));

    DefaultJSONParser parser = new DefaultJSONParser("null", ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);
    Assert.assertEquals(null, NumberDeserializer.instance.deserialze(parser, null, null));
    Assert.assertEquals(JSONToken.LITERAL_INT, NumberDeserializer.instance.getFastMatchToken());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:DoubleDeserializerTest.java


注:本文中的com.alibaba.fastjson.parser.ParserConfig.getGlobalInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。