Java Code Examples for com.alibaba.fastjson.parser.JSONToken#TRUE
The following examples show how to use
com.alibaba.fastjson.parser.JSONToken#TRUE .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BooleanCodec.java From uavstack with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") public <T> T deserialze(DefaultJSONParser parser, Type clazz, Object fieldName) { final JSONLexer lexer = parser.lexer; Boolean boolObj; try { if (lexer.token() == JSONToken.TRUE) { lexer.nextToken(JSONToken.COMMA); boolObj = Boolean.TRUE; } else if (lexer.token() == JSONToken.FALSE) { lexer.nextToken(JSONToken.COMMA); boolObj = Boolean.FALSE; } else if (lexer.token() == JSONToken.LITERAL_INT) { int intValue = lexer.intValue(); lexer.nextToken(JSONToken.COMMA); if (intValue == 1) { boolObj = Boolean.TRUE; } else { boolObj = Boolean.FALSE; } } else { Object value = parser.parse(); if (value == null) { return null; } boolObj = TypeUtils.castToBoolean(value); } } catch (Exception ex) { throw new JSONException("parseBoolean error, field : " + fieldName, ex); } if (clazz == AtomicBoolean.class) { return (T) new AtomicBoolean(boolObj.booleanValue()); } return (T) boolObj; }
Example 2
Source File: BooleanCodec.java From uavstack with Apache License 2.0 | 4 votes |
public int getFastMatchToken() { return JSONToken.TRUE; }