Java Code Examples for com.alibaba.fastjson.parser.DefaultJSONParser#getLexer()
The following examples show how to use
com.alibaba.fastjson.parser.DefaultJSONParser#getLexer() .
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: ValuedEnumDeserializer.java From stategen with GNU Affero General Public License v3.0 | 5 votes |
@SuppressWarnings("unchecked") @Override public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) { JSONLexer lexer = parser.getLexer(); String stringVal = lexer.stringVal(); return (T) EnumUtil.valueOf((Class<T>) type , stringVal); }
Example 4
Source File: AwtCodec.java From uavstack with Apache License 2.0 | 5 votes |
private Object parseRef(DefaultJSONParser parser, Object fieldName) { JSONLexer lexer = parser.getLexer(); lexer.nextTokenWithColon(JSONToken.LITERAL_STRING); String ref = lexer.stringVal(); parser.setContext(parser.getContext(), fieldName); parser.addResolveTask(new DefaultJSONParser.ResolveTask(parser.getContext(), ref)); parser.popContext(); parser.setResolveStatus(DefaultJSONParser.NeedToResolve); lexer.nextToken(JSONToken.RBRACE); parser.accept(JSONToken.RBRACE); return null; }
Example 5
Source File: FastJsonSObjectCodec.java From actframework with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) { JSONLexer lexer = parser.getLexer(); if (lexer.token() == JSONToken.LITERAL_STRING) { String text = lexer.stringVal(); lexer.nextToken(JSONToken.COMMA); return (T) resolver.resolve(text); } else { throw new UnsupportedOperationException(); } }
Example 6
Source File: FastJsonKeywordCodec.java From actframework with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) { JSONLexer lexer = parser.getLexer(); if (lexer.token() == JSONToken.LITERAL_STRING) { String text = lexer.stringVal(); lexer.nextToken(JSONToken.COMMA); return (T) Keyword.of(text); } else { throw new UnsupportedOperationException(); } }