本文整理汇总了Java中com.alibaba.fastjson.parser.DefaultJSONParser.getResolveStatus方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultJSONParser.getResolveStatus方法的具体用法?Java DefaultJSONParser.getResolveStatus怎么用?Java DefaultJSONParser.getResolveStatus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.alibaba.fastjson.parser.DefaultJSONParser
的用法示例。
在下文中一共展示了DefaultJSONParser.getResolveStatus方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseField
import com.alibaba.fastjson.parser.DefaultJSONParser; //导入方法依赖的package包/类
public void parseField(DefaultJSONParser parser, Object object, Type objectType, Map<String, Object> fieldValues) {
if (this.fieldValueDeserilizer == null) {
this.fieldValueDeserilizer = parser.getConfig().getDeserializer(this.fieldInfo);
}
if (objectType instanceof ParameterizedType) {
parser.getContext().setType(objectType);
}
Object value = this.fieldValueDeserilizer.deserialze(parser, getFieldType(), this.fieldInfo.getName());
if (parser.getResolveStatus() == 1) {
ResolveTask task = parser.getLastResolveTask();
task.setFieldDeserializer(this);
task.setOwnerContext(parser.getContext());
parser.setResolveStatus(0);
} else if (object == null) {
fieldValues.put(this.fieldInfo.getName(), value);
} else {
setValue(object, value);
}
}
示例2: parseField
import com.alibaba.fastjson.parser.DefaultJSONParser; //导入方法依赖的package包/类
@Override
public void parseField(DefaultJSONParser parser, Object object, Type objectType, Map<String, Object> fieldValues) {
if (fieldValueDeserilizer == null) {
fieldValueDeserilizer = parser.getConfig().getDeserializer(fieldInfo);
}
if (objectType instanceof ParameterizedType) {
ParseContext objContext = parser.getContext();
objContext.setType(objectType);
}
Object value = fieldValueDeserilizer.deserialze(parser, getFieldType(), fieldInfo.getName());
if (parser.getResolveStatus() == DefaultJSONParser.NeedToResolve) {
ResolveTask task = parser.getLastResolveTask();
task.setFieldDeserializer(this);
task.setOwnerContext(parser.getContext());
parser.setResolveStatus(DefaultJSONParser.NONE);
} else {
if (object == null) {
fieldValues.put(fieldInfo.getName(), value);
} else {
setValue(object, value);
}
}
}
示例3: parseField
import com.alibaba.fastjson.parser.DefaultJSONParser; //导入方法依赖的package包/类
@Override
public void parseField(DefaultJSONParser parser, Object object, Type objectType, Map<String, Object> fieldValues) {
if (fieldValueDeserilizer == null) {
getFieldValueDeserilizer(parser.getConfig());
}
Type fieldType = fieldInfo.fieldType;
if (objectType instanceof ParameterizedType) {
ParseContext objContext = parser.getContext();
objContext.type = objectType;
fieldType = FieldInfo.getFieldType(this.clazz, objectType, fieldType);
}
// ContextObjectDeserializer
Object value;
if (fieldValueDeserilizer instanceof JavaBeanDeserializer) {
JavaBeanDeserializer javaBeanDeser = (JavaBeanDeserializer) fieldValueDeserilizer;
value = javaBeanDeser.deserialze(parser, fieldType, fieldInfo.name, fieldInfo.parserFeatures);
} else {
if (this.fieldInfo.format != null && fieldValueDeserilizer instanceof ContextObjectDeserializer) {
value = ((ContextObjectDeserializer) fieldValueDeserilizer) //
.deserialze(parser, fieldType,
fieldInfo.name,
fieldInfo.format,
fieldInfo.parserFeatures);
} else {
value = fieldValueDeserilizer.deserialze(parser, fieldType, fieldInfo.name);
}
}
if (parser.getResolveStatus() == DefaultJSONParser.NeedToResolve) {
DefaultJSONParser.ResolveTask task = parser.getLastResolveTask();
task.fieldDeserializer = this;
task.ownerContext = parser.getContext();
parser.setResolveStatus(DefaultJSONParser.NONE);
} else {
if (object == null) {
fieldValues.put(fieldInfo.name, value);
} else {
setValue(object, value);
}
}
}
示例4: deserialze
import com.alibaba.fastjson.parser.DefaultJSONParser; //导入方法依赖的package包/类
public <T> T deserialze(DefaultJSONParser parser, Type clazz, Object fieldName) {
Long val;
JSONLexer lexer = parser.getLexer();
if (lexer.token() == 2) {
val = Long.valueOf(lexer.longValue());
lexer.nextToken(16);
} else if (lexer.token() == 4) {
String strVal = lexer.stringVal();
val = strVal;
lexer.nextToken(16);
if (lexer.isEnabled(Feature.AllowISO8601DateFormat)) {
JSONScanner iso8601Lexer = new JSONScanner(strVal);
if (iso8601Lexer.scanISO8601DateIfMatch()) {
val = iso8601Lexer.getCalendar().getTime();
}
iso8601Lexer.close();
}
} else if (lexer.token() == 8) {
lexer.nextToken();
val = null;
} else if (lexer.token() == 12) {
lexer.nextToken();
if (lexer.token() == 4) {
if (JSON.DEFAULT_TYPE_KEY.equals(lexer.stringVal())) {
lexer.nextToken();
parser.accept(17);
Class<?> type = TypeUtils.loadClass(lexer.stringVal());
if (type != null) {
clazz = type;
}
parser.accept(4);
parser.accept(16);
}
lexer.nextTokenWithColon(2);
if (lexer.token() == 2) {
long timeMillis = lexer.longValue();
lexer.nextToken();
val = Long.valueOf(timeMillis);
parser.accept(13);
} else {
throw new JSONException("syntax error : " + lexer.tokenName());
}
}
throw new JSONException("syntax error");
} else if (parser.getResolveStatus() == 2) {
parser.setResolveStatus(0);
parser.accept(16);
if (lexer.token() != 4) {
throw new JSONException("syntax error");
} else if ("val".equals(lexer.stringVal())) {
lexer.nextToken();
parser.accept(17);
val = parser.parse();
parser.accept(13);
} else {
throw new JSONException("syntax error");
}
} else {
val = parser.parse();
}
return cast(parser, clazz, fieldName, val);
}