com.alibaba.fastjson.parser.deserializer.PropertyProcessableDeserializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fastjson-to-easyjson Show documentation
Show all versions of fastjson-to-easyjson Show documentation
Adapter alibaba fastjson to other json libraries. the fastjson version: 1.2.58
package com.alibaba.fastjson.parser.deserializer;
import com.alibaba.fastjson.JSONException;
import com.alibaba.fastjson.parser.DefaultJSONParser;
import com.alibaba.fastjson.parser.JSONToken;
import java.lang.reflect.Type;
/**
* Created by wenshao on 15/07/2017.
*/
public class PropertyProcessableDeserializer implements ObjectDeserializer {
public final Class type;
public PropertyProcessableDeserializer(Class type) {
this.type = type;
}
public T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
PropertyProcessable processable;
try {
processable = this.type.newInstance();
} catch (Exception e) {
throw new JSONException("craete instance error");
}
Object object = parser.parse(processable, fieldName);
return (T) object;
}
public int getFastMatchToken() {
return JSONToken.LBRACE;
}
}