com.fastchar.extend.fastjson.FastJsonProvider Maven / Gradle / Ivy
package com.fastchar.extend.fastjson;
import com.alibaba.fastjson.JSON;
import com.fastchar.annotation.AFastClassFind;
import com.fastchar.interfaces.IFastJsonProvider;
import com.fastchar.utils.FastClassUtils;
import java.lang.reflect.Type;
/**
* FastJson https://github.com/alibaba/fastjson
*/
@AFastClassFind("com.alibaba.fastjson.JSON")
public class FastJsonProvider implements IFastJsonProvider {
@Override
public String toJson(Object value) {
return JSON.toJSONString(value);
}
@Override
public T fromJson(String json, Class targetClass) {
return JSON.parseObject(json, targetClass);
}
@Override
public T fromJson(String json, Type targetType) {
return JSON.parseObject(json, targetType);
}
}