Package com.alibaba.fastjson.parser

Examples of com.alibaba.fastjson.parser.DefaultJSONParser


  }

  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


  }

  public void test_error4() {
    Exception error = null;
    try {
      DefaultJSONParser parser = new DefaultJSONParser("]");
      parser.parse();
    } catch (Exception ex) {
      error = ex;
    }
    Assert.assertNotNull(error);
  }
View Full Code Here

  }

  public void test_error6() {
    Exception error = null;
    try {
      DefaultJSONParser parser = new DefaultJSONParser("{\"a\"33");
      parser.parse();
    } catch (Exception ex) {
      error = ex;
    }
    Assert.assertNotNull(error);
  }
View Full Code Here

  }

  public void test_error7() {
    Exception error = null;
    try {
      DefaultJSONParser parser = new DefaultJSONParser("{\"a\":{}3");
      parser.parse();
    } catch (Exception ex) {
      error = ex;
    }
    Assert.assertNotNull(error);
  }
View Full Code Here

  }

  public void test_error11() {
    Exception error = null;
    try {
      DefaultJSONParser parser = new DefaultJSONParser("{]");
      parser.parse();
    } catch (Exception ex) {
      error = ex;
    }
    Assert.assertNotNull(error);
  }
View Full Code Here

    public void f_ali_json() throws Exception {
        // String input = "[{\"a\":3}]";
        long startNano = System.nanoTime();
        for (int i = 0; i < COUNT; ++i) {
            DefaultJSONParser parser = new DefaultJSONParser(text);
            parser.parse();
        }
        long nano = System.nanoTime() - startNano;
        System.out.println("fast-json \t: " + NumberFormat.getInstance().format(nano));
    }
View Full Code Here

public class DefaultJSONParserTest_error extends TestCase {

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

    }
   
    public void test_error_2() {
        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);
    }
View Full Code Here

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

            DefaultExtJSONParser ext = new DefaultExtJSONParser(t);
            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

TOP

Related Classes of com.alibaba.fastjson.parser.DefaultJSONParser

Copyright © 2018 www.massapicom. 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.