Package com.alibaba.fastjson.parser

Examples of com.alibaba.fastjson.parser.JSONScanner.token()


        JSONScanner lexer = new JSONScanner("2000-02-10T00:00:00.000");
        lexer.config(Feature.AllowISO8601DateFormat, true);
        Assert.assertEquals(true, lexer.scanISO8601DateIfMatch());
        Assert.assertEquals(JSONToken.LITERAL_ISO8601_DATE, lexer.token());
        lexer.nextToken();
        Assert.assertEquals(JSONToken.EOF, lexer.token());
    }

    public void test_3() throws Exception {
        JSONScanner lexer = new JSONScanner("2000-2");
        lexer.config(Feature.AllowISO8601DateFormat, true);
View Full Code Here


    public void test_3() throws Exception {
        JSONScanner lexer = new JSONScanner("2000-2");
        lexer.config(Feature.AllowISO8601DateFormat, true);
        lexer.nextToken();
        Assert.assertEquals(JSONToken.LITERAL_INT, lexer.token());
        lexer.nextToken();
        Assert.assertEquals(JSONToken.LITERAL_INT, lexer.token());
        lexer.nextToken();
        Assert.assertEquals(JSONToken.EOF, lexer.token());
    }
View Full Code Here

    public void test_1() throws Exception {
        JSONScanner lexer = new JSONScanner("\"value\":\"aa\"},");
        String text = lexer.scanFieldSymbol("\"value\":".toCharArray(), new SymbolTable());
        Assert.assertEquals("aa", text);
        Assert.assertEquals(JSONScanner.END, lexer.matchStat);
        Assert.assertEquals(JSONToken.COMMA, lexer.token());
    }
   
    public void test_2() throws Exception {
        JSONScanner lexer = new JSONScanner("\"value\":\"aa\"}]");
        String text = lexer.scanFieldSymbol("\"value\":".toCharArray(), new SymbolTable());
View Full Code Here

    public void test_2() throws Exception {
        JSONScanner lexer = new JSONScanner("\"value\":\"aa\"}]");
        String text = lexer.scanFieldSymbol("\"value\":".toCharArray(), new SymbolTable());
        Assert.assertEquals("aa", text);
        Assert.assertEquals(JSONScanner.END, lexer.matchStat);
        Assert.assertEquals(JSONToken.RBRACKET, lexer.token());
    }
   
    public void test_3() throws Exception {
        JSONScanner lexer = new JSONScanner("\"value\":\"aa\"}}");
        String text = lexer.scanFieldSymbol("\"value\":".toCharArray(), new SymbolTable());
View Full Code Here

    public void test_3() throws Exception {
        JSONScanner lexer = new JSONScanner("\"value\":\"aa\"}}");
        String text = lexer.scanFieldSymbol("\"value\":".toCharArray(), new SymbolTable());
        Assert.assertEquals("aa", text);
        Assert.assertEquals(JSONScanner.END, lexer.matchStat);
        Assert.assertEquals(JSONToken.RBRACE, lexer.token());
    }
   
    public void test_4() throws Exception {
      JSONScanner lexer = new JSONScanner("\"value\":\"aa\"}");
      String text = lexer.scanFieldSymbol("\"value\":".toCharArray(), new SymbolTable());
View Full Code Here

    public void test_4() throws Exception {
      JSONScanner lexer = new JSONScanner("\"value\":\"aa\"}");
      String text = lexer.scanFieldSymbol("\"value\":".toCharArray(), new SymbolTable());
      Assert.assertEquals("aa", text);
      Assert.assertEquals(JSONScanner.END, lexer.matchStat);
      Assert.assertEquals(JSONToken.EOF, lexer.token());
    }
   
    public void test_6() throws Exception {
      JSONScanner lexer = new JSONScanner("\"value\":\"aa\"}{");
      String text = lexer.scanFieldSymbol("\"value\":".toCharArray(), new SymbolTable());
View Full Code Here

        JSONScanner lexer = new JSONScanner("2000-2");
        lexer.config(Feature.AllowISO8601DateFormat, true);
        lexer.nextToken();
        Assert.assertEquals(JSONToken.LITERAL_INT, lexer.token());
        lexer.nextToken();
        Assert.assertEquals(JSONToken.LITERAL_INT, lexer.token());
        lexer.nextToken();
        Assert.assertEquals(JSONToken.EOF, lexer.token());
    }
}
View Full Code Here

        lexer.nextToken();
        Assert.assertEquals(JSONToken.LITERAL_INT, lexer.token());
        lexer.nextToken();
        Assert.assertEquals(JSONToken.LITERAL_INT, lexer.token());
        lexer.nextToken();
        Assert.assertEquals(JSONToken.EOF, lexer.token());
    }
}
View Full Code Here

        Exception error = null;
        try {
            JSONScanner lexer = new JSONScanner("'k\\k'");
            lexer.config(Feature.AllowSingleQuotes, true);
            lexer.nextToken();
            Assert.assertEquals(JSONToken.ERROR, lexer.token());
        } catch (JSONException ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
View Full Code Here

  public Object parseMap(DefaultJSONParser parser, Map<Object, Object> map,
      Type keyType, Type valueType, Object fieldName) {
    JSONScanner lexer = (JSONScanner) parser.getLexer();

    if (lexer.token() != JSONToken.LBRACE
        && lexer.token() != JSONToken.COMMA) {
      throw new JSONException("syntax error, expect {, actual "
          + lexer.tokenName());
    }
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.