Package com.alibaba.fastjson.parser

Examples of com.alibaba.fastjson.parser.DefaultExtJSONParser.config()


    public void test_error_5() throws Exception {
        JSONException error = null;
        try {
            DefaultExtJSONParser parser = new DefaultExtJSONParser("{a:3}");
            parser.config(Feature.AllowUnQuotedFieldNames, false);
            parser.parseObject(A.class);
        } catch (JSONException e) {
            error = e;
        }
        Assert.assertNotNull(error);
View Full Code Here


    public void test_error_6() throws Exception {
        JSONException error = null;
        try {
            DefaultExtJSONParser parser = new DefaultExtJSONParser("{'a':3}");
            parser.config(Feature.AllowSingleQuotes, false);
            parser.parseObject(A.class);
        } catch (JSONException e) {
            error = e;
        }
        Assert.assertNotNull(error);
View Full Code Here

public class DefaultExtJSONParserTest_6 extends TestCase {

    public void test_0() throws Exception {
        DefaultExtJSONParser parser = new DefaultExtJSONParser("{value:{,,,,\"value\":3,\"id\":1}}");
        parser.config(Feature.AllowArbitraryCommas, true);
        Entity entity = new Entity();
        parser.parseObject(entity);
        Assert.assertEquals(3, entity.getValue().getValue());
    }
View Full Code Here

        Assert.assertEquals(3, entity.getValue().getValue());
    }

    public void test_1() throws Exception {
        DefaultExtJSONParser parser = new DefaultExtJSONParser("{'value':{\"value\":3,\"id\":1}}");
        parser.config(Feature.AllowArbitraryCommas, false);
        Entity entity = new Entity();
        parser.parseObject(entity);
        Assert.assertEquals(3, entity.getValue().getValue());
    }
View Full Code Here

  public void test_0() throws Exception {
    DefaultExtJSONParser parser = new DefaultExtJSONParser("123");
    Assert.assertEquals(new Integer(123), (Integer) parser.parse());

    parser.config(Feature.IgnoreNotMatch, false);
  }

  public void test_1() throws Exception {
    DefaultExtJSONParser parser = new DefaultExtJSONParser("[]");
    parser.parseArray(Class.class);
View Full Code Here

        return "fastjson";
    }

    public <T> T decodeObject(String text, Class<T> clazz) {
        DefaultExtJSONParser parser = new DefaultExtJSONParser(text, config);
        parser.config(Feature.DisableCircularReferenceDetect, true);
        return parser.parseObject(clazz);
    }

    public <T> Collection<T> decodeArray(String text, Class<T> clazz) throws Exception {
        DefaultExtJSONParser parser = new DefaultExtJSONParser(text, config);
View Full Code Here

        return parser.parseObject(clazz);
    }

    public <T> Collection<T> decodeArray(String text, Class<T> clazz) throws Exception {
        DefaultExtJSONParser parser = new DefaultExtJSONParser(text, config);
        parser.config(Feature.DisableCircularReferenceDetect, true);
        return parser.parseArray(clazz);
    }

    public final Object decodeObject(String text) {
        DefaultJSONParser parser = new DefaultJSONParser(text, config);
View Full Code Here

        Assert.assertNotNull(error);
    }

    public void test_parse_str() throws Exception {
        DefaultExtJSONParser parser = new DefaultExtJSONParser("\"1\"");
        parser.config(Feature.AllowISO8601DateFormat, true);
        Assert.assertEquals("1", parser.parse());

    }

    public void test_parseArray() throws Exception {
View Full Code Here

    }

    public void test_parseArray() throws Exception {
        DefaultExtJSONParser parser = new DefaultExtJSONParser("[1]");
        parser.config(Feature.AllowArbitraryCommas, false);
        List<String> list = new ArrayList<String>();
        parser.parseArray(String.class, list);
        Assert.assertEquals(1, list.size());
    }
View Full Code Here

        Assert.assertEquals(1, list.size());
    }

    public void test_parseArray_error() throws Exception {
        DefaultExtJSONParser parser = new DefaultExtJSONParser("[1,2}");
        parser.config(Feature.AllowArbitraryCommas, false);
        List<String> list = new ArrayList<String>();

        Exception error = null;
        try {
            parser.parseArray(String.class, list);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.