All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.alibaba.fastjson.parser.deserializer.PropertyProcessableDeserializer Maven / Gradle / Ivy

There is a newer version: 3.2.26
Show newest version
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;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy