io.github.rhwayfun.springboot.rocketmq.starter.serialize.json.JsonSerialzation Maven / Gradle / Ivy
package io.github.rhwayfun.springboot.rocketmq.starter.serialize.json;
import com.alibaba.fastjson.JSON;
import io.github.rhwayfun.springboot.rocketmq.starter.serialize.MsgBody;
/**
* @author rhwayfun
* @since 0.0.1
*/
public class JsonSerialzation implements MsgBody {
private final String body;
public JsonSerialzation(String body) {
this.body = body;
}
@Override
public T getBody(Class clazz) {
if (null == body || "".equals(body.trim())) {
return null;
}
return JSON.parseObject(body, clazz);
}
}