mirror of
https://gitee.com/dromara/sa-token.git
synced 2026-02-27 16:50:24 +08:00
test: 新增 json 序列化插件的单元测试
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package cn.dev33.satoken.json;
|
||||
|
||||
import cn.dev33.satoken.util.SaFoxUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
|
||||
/**
|
||||
@@ -30,6 +31,9 @@ public class SaJsonTemplateForFastjson implements SaJsonTemplate {
|
||||
*/
|
||||
@Override
|
||||
public String objectToJson(Object obj) {
|
||||
if(SaFoxUtil.isEmpty(obj)) {
|
||||
return null;
|
||||
}
|
||||
return JSON.toJSONString(obj);
|
||||
}
|
||||
|
||||
@@ -38,6 +42,9 @@ public class SaJsonTemplateForFastjson implements SaJsonTemplate {
|
||||
*/
|
||||
@Override
|
||||
public<T> T jsonToObject(String jsonStr, Class<T> type) {
|
||||
if(SaFoxUtil.isEmpty(jsonStr)) {
|
||||
return null;
|
||||
}
|
||||
return JSON.parseObject(jsonStr, type);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user