Package com.alibaba.fastjson.parser

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


        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));
    }
View Full Code Here


        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));
    }
}
View Full Code Here

public class DefaultJSONParserTest extends TestCase {

  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);
  }
View Full Code Here

    Assert.assertEquals(3.4D, result);
  }

  public void test_double_in_object() {
    DefaultJSONParser parser = new DefaultJSONParser("{\"double\":3.4}");
    parser.config(Feature.UseBigDecimal, false);
    Assert.assertEquals("{\"double\":3.4}", parser.getInput());
    Object result = parser.parse();
    Assert.assertEquals(3.4D, ((Map) result).get("double"));
  }
View Full Code Here

    public void test_2() throws Exception {
        JSONException error = null;
        try {
            DefaultJSONParser parser = new DefaultJSONParser("{'a'3}");
            parser.config(Feature.AllowSingleQuotes, true);
            parser.parse();
        } catch (JSONException e) {
            error = e;
        }
        Assert.assertNotNull(error);
View Full Code Here

    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);
View Full Code Here

    public void test_4() throws Exception {
        JSONException error = null;
        try {
            DefaultJSONParser parser = new DefaultJSONParser("{");
            parser.config(Feature.AllowUnQuotedFieldNames, true);
            parser.parse();
        } catch (JSONException e) {
            error = e;
        }
        Assert.assertNotNull(error);
View Full Code Here

            ext.config(Feature.AllowArbitraryCommas, true);
            List<Object> extRes = ext.parseArray(Object.class);
            Assert.assertEquals(res, extRes);

            DefaultJSONParser basic = new DefaultJSONParser(t);
            basic.config(Feature.AllowArbitraryCommas, true);
            List<Object> basicRes = new ArrayList<Object>();
            basic.parseArray(basicRes);
            Assert.assertEquals(res, basicRes);
        }
    }
View Full Code Here

            JSONObject extRes = ext.parseObject();
            Assert.assertEquals(res.toString(), extRes.toString());

            DefaultJSONParser basic = new DefaultJSONParser(t);
            basic.config(Feature.AllowArbitraryCommas, true);
            JSONObject basicRes = basic.parseObject();
            Assert.assertEquals(res.toString(), basicRes.toString());
        }
    }
View Full Code Here

public class FeatureParserTest extends TestCase {

    public void test_AllowSingleQuotes_0() throws Exception {
        DefaultJSONParser parser = new DefaultJSONParser("{'a':3}");
        parser.config(Feature.AllowSingleQuotes, true);
        JSONObject json = (JSONObject) parser.parse();
        Assert.assertEquals(1, json.size());
        Assert.assertEquals(new Integer(3), (Integer) json.getInteger("a"));
    }
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.