Package com.alibaba.fastjson.parser

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


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


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

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

  public void test_error3() {
    Exception error = null;
    try {
      DefaultJSONParser parser = new DefaultJSONParser("33");
      parser.parseObject(new HashMap());
    } catch (Exception ex) {
      error = ex;
    }
    Assert.assertNotNull(error);
  }
View Full Code Here

        Assert.assertNotNull(error);
    }

    public void test_5() throws Exception {
        DefaultJSONParser parser = new DefaultJSONParser("{}");
        Map map = parser.parseObject();
        Assert.assertEquals(0, map.size());
    }
}
View Full Code Here

public class JSONReaderScannerTest_chars 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

    }
   
    public void test_long() throws Exception {
        char[] chars = "{\"value\":3L}".toCharArray();
        DefaultJSONParser parser = new DefaultJSONParser(new JSONReaderScanner(chars, chars.length));
        JSONObject json = parser.parseObject();
        Assert.assertTrue(3L == ((Long) json.get("value")).longValue());
        parser.close();
    }
}
View Full Code Here

import com.alibaba.fastjson.parser.JSONReaderScanner;

public class JSONReaderScannerTest_boolean extends TestCase {
  public void test_true() throws Exception {
    DefaultJSONParser parser = new DefaultJSONParser(new JSONReaderScanner("{\"name\":true}"));
    JSONObject json = parser.parseObject();
    Assert.assertEquals(Boolean.TRUE, json.get("name"));
    parser.close();
  }
 
  public void test_false() 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.