Search in sources :

Example 96 with JSONScanner

use of com.alibaba.fastjson.parser.JSONScanner in project fastjson by alibaba.

the class JSONScannerTest_true method test_scan_true_9.

public void test_scan_true_9() throws Exception {
    JSONScanner lexer = new JSONScanner("true\na");
    lexer.scanTrue();
}
Also used : JSONScanner(com.alibaba.fastjson.parser.JSONScanner)

Example 97 with JSONScanner

use of com.alibaba.fastjson.parser.JSONScanner in project fastjson by alibaba.

the class JSONScannerTest_true method test_scan_false_14.

public void test_scan_false_14() throws Exception {
    JSONScanner lexer = new JSONScanner("true}");
    lexer.scanTrue();
}
Also used : JSONScanner(com.alibaba.fastjson.parser.JSONScanner)

Example 98 with JSONScanner

use of com.alibaba.fastjson.parser.JSONScanner in project fastjson by alibaba.

the class MediaContentDeserializer method deserialze.

public <T> T deserialze(DefaultJSONParser parser, Type clazz, Object fieldName) {
    final JSONScanner lexer = (JSONScanner) parser.getLexer();
    MediaContent object = new MediaContent();
    lexer.matchField(mediaPrefix);
    if (mediaDeserializer == null) {
    //mediaDeserializer = parser.getMapping().getDeserializer(ObjectDeserializer.class);
    }
    mediaDeserializer.deserialze(parser, clazz, null);
    lexer.matchField(imagePrefix);
    imageDeserializer.deserialze(parser, clazz, null);
    // TODO Auto-generated method stub
    return null;
}
Also used : JSONScanner(com.alibaba.fastjson.parser.JSONScanner)

Example 99 with JSONScanner

use of com.alibaba.fastjson.parser.JSONScanner in project fastjson by alibaba.

the class LexerTest method test_empty.

public void test_empty() throws Exception {
    JSONScanner lexer = new JSONScanner("".toCharArray(), 0);
    lexer.nextToken();
    Assert.assertEquals(JSONToken.EOF, lexer.token());
}
Also used : JSONScanner(com.alibaba.fastjson.parser.JSONScanner)

Example 100 with JSONScanner

use of com.alibaba.fastjson.parser.JSONScanner in project fastjson by alibaba.

the class LexerTest method test_float.

public void test_float() throws Exception {
    String text = "123456789.0123";
    JSONScanner lexer = new JSONScanner(text);
    lexer.nextToken();
    BigDecimal decimalValue = lexer.decimalValue();
    Assert.assertEquals(new BigDecimal("123456789.0123"), decimalValue);
}
Also used : JSONScanner(com.alibaba.fastjson.parser.JSONScanner) BigDecimal(java.math.BigDecimal)

Aggregations

JSONScanner (com.alibaba.fastjson.parser.JSONScanner)179 JSONException (com.alibaba.fastjson.JSONException)37 SymbolTable (com.alibaba.fastjson.parser.SymbolTable)15 JSONReader (com.alibaba.fastjson.JSONReader)11 ParseException (java.text.ParseException)5 BigInteger (java.math.BigInteger)3 DateFormat (java.text.DateFormat)3 SimpleDateFormat (java.text.SimpleDateFormat)3 Date (java.util.Date)3 JSONLexer (com.alibaba.fastjson.parser.JSONLexer)2 JSONObject (com.alibaba.fastjson.JSONObject)1 AccessibleObject (java.lang.reflect.AccessibleObject)1 BigDecimal (java.math.BigDecimal)1 AccessControlException (java.security.AccessControlException)1 Calendar (java.util.Calendar)1