Package com.alibaba.fastjson.parser

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


    parser.close();
  }
 
  public void test_false() throws Exception {
    DefaultJSONParser parser = new DefaultJSONParser(new JSONReaderScanner("{\"name\":false}"));
    JSONObject json = parser.parseObject();
    Assert.assertEquals(Boolean.FALSE, json.get("name"));
    parser.close();
  }
}
View Full Code Here


public class JSONReaderScannerTest_matchField extends TestCase {

    public void test_true() throws Exception {
        DefaultJSONParser parser = new DefaultJSONParser(new JSONReaderScanner("{\"items\":[{}],\"value\":{}}"));
        VO vo = parser.parseObject(VO.class);
        Assert.assertNotNull(vo.getValue());
        Assert.assertNotNull(vo.getItems());
        Assert.assertEquals(1, vo.getItems().size());
        Assert.assertNotNull(vo.getItems().get(0));
        parser.close();
View Full Code Here

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

        if (processor instanceof ExtraProcessor) {
            parser.getExtraProcessors().add((ExtraProcessor) processor);
        }

        T value = (T) parser.parseObject(clazz);

        parser.handleResovleTask(value);

        parser.close();
View Full Code Here

        for (Feature featrue : features) {
            featureValues = Feature.config(featureValues, featrue, true);
        }

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

        parser.handleResovleTask(value);

        parser.close();
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());
        }
    }

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

public class Bug_for_akvadrako extends TestCase {

    public void testNakedFields() throws Exception {
        Naked naked = new Naked();
        DefaultJSONParser parser = new DefaultJSONParser("{ \"field\": 3 }");
        parser.parseObject(naked);
    }

    public static class Naked {

        public int field;
View Full Code Here

public class JSONReaderScannerTest_negative extends TestCase {

    public void test_double() throws Exception {
        char[] chars = "{\"value\":-3.5D}".toCharArray();
        DefaultJSONParser parser = new DefaultJSONParser(new JSONReaderScanner(chars, chars.length));
        JSONObject json = parser.parseObject();
        Assert.assertTrue(-3.5D == ((Double) json.get("value")).doubleValue());
        parser.close();
    }

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

    }

    public void test_float() throws Exception {
        char[] chars = "{\"value\":-3.5F}".toCharArray();
        DefaultJSONParser parser = new DefaultJSONParser(new JSONReaderScanner(chars, chars.length));
        JSONObject json = parser.parseObject();
        Assert.assertTrue(-3.5F == ((Float) json.get("value")).doubleValue());
        parser.close();
    }

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

    }

    public void test_decimal() throws Exception {
        char[] chars = "{\"value\":-3.5}".toCharArray();
        DefaultJSONParser parser = new DefaultJSONParser(new JSONReaderScanner(chars, chars.length));
        JSONObject json = parser.parseObject();
        Assert.assertEquals(new BigDecimal("-3.5"), json.get("value"));
        parser.close();
    }
   
    public void test_long() throws Exception {
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.