Package com.alibaba.fastjson.parser

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


        ArrayList list = new ArrayList();
        parser.config(Feature.AllowISO8601DateFormat, false);

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


        DefaultExtJSONParser parser = new DefaultExtJSONParser("{1,null }");
        parser.config(Feature.AllowISO8601DateFormat, false);

        Exception error = null;
        try {
            parser.parseArray(new Type[] { String.class });
        } catch (Exception ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
View Full Code Here

        DefaultExtJSONParser parser = new DefaultExtJSONParser("{1}");
        parser.config(Feature.AllowISO8601DateFormat, false);

        Exception error = null;
        try {
            parser.parseArray(new Type[] {});
        } catch (Exception ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
View Full Code Here

        DefaultExtJSONParser parser = new DefaultExtJSONParser("[1,2,3 4]");
        parser.config(Feature.AllowISO8601DateFormat, false);

        Exception error = null;
        try {
            parser.parseArray(new Type[] { Integer.class });
        } catch (Exception ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
View Full Code Here

        String[] tests = { "[1,2,3]", "[1,,2,3]", "[1,2,,,3]", "[1 2,,,3]", "[1 2 3]", "[1, 2, 3,,]", "[,,1, 2, 3,,]", };

        for (String t : tests) {
            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>();
View Full Code Here

    public void test_error_0() throws Exception {
        Exception error = null;
        try {
            String text = "[{\"old\":false,\"name\":\"校长\",\"age\":3,\"salary\":123456789.0123]";
            DefaultExtJSONParser parser = new DefaultExtJSONParser(text);
            parser.parseArray(User.class);
        } catch (Exception ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
View Full Code Here

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

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

  public void test_2() throws Exception {
    DefaultExtJSONParser parser = new DefaultExtJSONParser("{}");
    parser.parseObject(Object.class);
View Full Code Here

  public void test_error_1() throws Exception {
    JSONException error = null;
    try {
      DefaultExtJSONParser parser = new DefaultExtJSONParser("[{}]");
      parser.parseArray(Class.class);
    } catch (JSONException e) {
      error = e;
    }
    Assert.assertNotNull(error);
  }
View Full Code Here

  public void test_error_2() throws Exception {
    JSONException error = null;
    try {
      DefaultExtJSONParser parser = new DefaultExtJSONParser(
          "{\"errorValue\":33}");
      parser.parseArray(User.class);
    } catch (JSONException e) {
      error = e;
    }
    Assert.assertNotNull(error);
  }
View Full Code Here

  public void test_error_3() throws Exception {
    JSONException error = null;
    try {
      DefaultExtJSONParser parser = new DefaultExtJSONParser(
          "{\"age\"33}");
      parser.parseArray(User.class);
    } catch (JSONException e) {
      error = e;
    }
    Assert.assertNotNull(error);
  }
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.