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

com.jd.blockchain.utils.serialize.json.JSONStringDeserializer Maven / Gradle / Ivy

There is a newer version: 1.4.0.RELEASE
Show newest version
package com.jd.blockchain.utils.serialize.json;

import java.lang.reflect.Type;

import com.alibaba.fastjson.parser.DefaultJSONParser;
import com.alibaba.fastjson.parser.JSONToken;
import com.alibaba.fastjson.parser.deserializer.ObjectDeserializer;

public class JSONStringDeserializer implements ObjectDeserializer{

	@SuppressWarnings("unchecked")
	@Override
	public  T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
		if (type instanceof Class && JSONString.class.isAssignableFrom((Class) type)) {
			String jsonString = parser.parseObject(String.class);
			return (T) new JSONString(jsonString);
		}
		return (T) parser.parse(fieldName);
	}

	@Override
	public int getFastMatchToken() {
		return JSONToken.LBRACE;
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy