Java Code Examples for com.alibaba.fastjson.parser.JSONToken#LBRACE
The following examples show how to use
com.alibaba.fastjson.parser.JSONToken#LBRACE .
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: AbstractInvocationCodec.java From joyrpc with Apache License 2.0 | 5 votes |
@Override public <T> T deserialze(final DefaultJSONParser parser, final Type type, final Object fieldName) { JSONLexer lexer = parser.getLexer(); switch (lexer.token()) { case JSONToken.NULL: lexer.nextToken(); return null; case JSONToken.LBRACE: return (T) parse(parser, lexer); default: return null; } }
Example 2
Source File: AbstractResponsePayloadCodec.java From joyrpc with Apache License 2.0 | 5 votes |
@Override public <T> T deserialze(final DefaultJSONParser parser, final Type type, final Object fieldName) { JSONLexer lexer = parser.getLexer(); switch (lexer.token()) { case JSONToken.NULL: lexer.nextToken(); return null; case JSONToken.LBRACE: return (T) parse(parser, lexer); default: return null; } }
Example 3
Source File: AbstractSerializer.java From joyrpc with Apache License 2.0 | 5 votes |
/** * 读取MAP * * @param parser 解析器 * @param lexer 文法 * @param field 字段 */ protected Map<String, Object> parseMap(final DefaultJSONParser parser, final JSONLexer lexer, final String field) { Map<String, Object> result = null; switch (lexer.token()) { case JSONToken.LBRACE: result = parser.parseObject(); break; case JSONToken.NULL: lexer.nextToken(); break; default: throw new SerializerException("syntax error: invalid " + field); } return result; }
Example 4
Source File: AwtCodec.java From uavstack with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) { JSONLexer lexer = parser.lexer; if (lexer.token() == JSONToken.NULL) { lexer.nextToken(JSONToken.COMMA); return null; } if (lexer.token() != JSONToken.LBRACE && lexer.token() != JSONToken.COMMA) { throw new JSONException("syntax error"); } lexer.nextToken(); T obj; if (type == Point.class) { obj = (T) parsePoint(parser, fieldName); } else if (type == Rectangle.class) { obj = (T) parseRectangle(parser); } else if (type == Color.class) { obj = (T) parseColor(parser); } else if (type == Font.class) { obj = (T) parseFont(parser); } else { throw new JSONException("not support awt class : " + type); } ParseContext context = parser.getContext(); parser.setContext(obj, fieldName); parser.setContext(context); return obj; }
Example 5
Source File: LongCodec.java From uavstack with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") public <T> T deserialze(DefaultJSONParser parser, Type clazz, Object fieldName) { final JSONLexer lexer = parser.lexer; Long longObject; try { final int token = lexer.token(); if (token == JSONToken.LITERAL_INT) { long longValue = lexer.longValue(); lexer.nextToken(JSONToken.COMMA); longObject = Long.valueOf(longValue); } else if (token == JSONToken.LITERAL_FLOAT) { BigDecimal number = lexer.decimalValue(); longObject = TypeUtils.longValue(number); lexer.nextToken(JSONToken.COMMA); } else { if (token == JSONToken.LBRACE) { JSONObject jsonObject = new JSONObject(true); parser.parseObject(jsonObject); longObject = TypeUtils.castToLong(jsonObject); } else { Object value = parser.parse(); longObject = TypeUtils.castToLong(value); } if (longObject == null) { return null; } } } catch (Exception ex) { throw new JSONException("parseLong error, field : " + fieldName, ex); } return clazz == AtomicLong.class // ? (T) new AtomicLong(longObject.longValue()) // : (T) longObject; }
Example 6
Source File: ASMDeserializerFactory.java From uavstack with Apache License 2.0 | 5 votes |
private void _quickNextToken(Context context, MethodVisitor mw, int token) { Label quickElse_ = new Label(), quickEnd_ = new Label(); mw.visitVarInsn(ALOAD, context.var("lexer")); mw.visitMethodInsn(INVOKEVIRTUAL, JSONLexerBase, "getCurrent", "()C"); if (token == JSONToken.LBRACE) { mw.visitVarInsn(BIPUSH, '{'); } else if (token == JSONToken.LBRACKET) { mw.visitVarInsn(BIPUSH, '['); } else { throw new IllegalStateException(); } mw.visitJumpInsn(IF_ICMPNE, quickElse_); mw.visitVarInsn(ALOAD, context.var("lexer")); mw.visitMethodInsn(INVOKEVIRTUAL, JSONLexerBase, "next", "()C"); mw.visitInsn(POP); mw.visitVarInsn(ALOAD, context.var("lexer")); mw.visitLdcInsn(token); mw.visitMethodInsn(INVOKEVIRTUAL, JSONLexerBase, "setToken", "(I)V"); mw.visitJumpInsn(GOTO, quickEnd_); mw.visitLabel(quickElse_); mw.visitVarInsn(ALOAD, context.var("lexer")); mw.visitLdcInsn(token); mw.visitMethodInsn(INVOKEVIRTUAL, JSONLexerBase, "nextToken", "(I)V"); mw.visitLabel(quickEnd_); }
Example 7
Source File: ReferenceCodec.java From uavstack with Apache License 2.0 | 4 votes |
public int getFastMatchToken() { return JSONToken.LBRACE; }
Example 8
Source File: AbstractInvocationCodec.java From joyrpc with Apache License 2.0 | 4 votes |
@Override public int getFastMatchToken() { return JSONToken.LBRACE; }
Example 9
Source File: AwtCodec.java From uavstack with Apache License 2.0 | 4 votes |
public int getFastMatchToken() { return JSONToken.LBRACE; }
Example 10
Source File: IntegerCodec.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; final int token = lexer.token(); if (token == JSONToken.NULL) { lexer.nextToken(JSONToken.COMMA); return null; } Integer intObj; try { if (token == JSONToken.LITERAL_INT) { int val = lexer.intValue(); lexer.nextToken(JSONToken.COMMA); intObj = Integer.valueOf(val); } else if (token == JSONToken.LITERAL_FLOAT) { BigDecimal number = lexer.decimalValue(); intObj = TypeUtils.intValue(number); lexer.nextToken(JSONToken.COMMA); } else { if (token == JSONToken.LBRACE) { JSONObject jsonObject = new JSONObject(true); parser.parseObject(jsonObject); intObj = TypeUtils.castToInt(jsonObject); } else { Object value = parser.parse(); intObj = TypeUtils.castToInt(value); } } } catch (Exception ex) { throw new JSONException("parseInt error, field : " + fieldName, ex); } if (clazz == AtomicInteger.class) { return (T) new AtomicInteger(intObj.intValue()); } return (T) intObj; }
Example 11
Source File: StackTraceElementDeserializer.java From uavstack with Apache License 2.0 | 4 votes |
public int getFastMatchToken() { return JSONToken.LBRACE; }
Example 12
Source File: JavaBeanDeserializer.java From uavstack with Apache License 2.0 | 4 votes |
public int getFastMatchToken() { return JSONToken.LBRACE; }
Example 13
Source File: ThrowableDeserializer.java From uavstack with Apache License 2.0 | 4 votes |
public int getFastMatchToken() { return JSONToken.LBRACE; }
Example 14
Source File: OptionalCodec.java From uavstack with Apache License 2.0 | 4 votes |
public int getFastMatchToken() { return JSONToken.LBRACE; }
Example 15
Source File: JavaObjectDeserializer.java From uavstack with Apache License 2.0 | 4 votes |
public int getFastMatchToken() { return JSONToken.LBRACE; }
Example 16
Source File: PropertyProcessableDeserializer.java From uavstack with Apache License 2.0 | 4 votes |
public int getFastMatchToken() { return JSONToken.LBRACE; }
Example 17
Source File: AbstractResponsePayloadCodec.java From joyrpc with Apache License 2.0 | 4 votes |
@Override public int getFastMatchToken() { return JSONToken.LBRACE; }