mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix code
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package cn.hutool.json.serialize;
|
||||
|
||||
import cn.hutool.core.lang.func.Wrapper;
|
||||
|
||||
/**
|
||||
* {@code JSONString}接口定义了一个{@code toJSONString()}<br>
|
||||
* 实现此接口的类可以通过实现{@code toJSONString()}方法来改变转JSON字符串的方式。
|
||||
@@ -8,7 +10,7 @@ package cn.hutool.json.serialize;
|
||||
*
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface JSONString {
|
||||
public interface JSONString extends Wrapper<Object> {
|
||||
|
||||
/**
|
||||
* 自定义转JSON字符串的方法
|
||||
@@ -22,6 +24,7 @@ public interface JSONString {
|
||||
*
|
||||
* @return 原始对象
|
||||
*/
|
||||
@Override
|
||||
default Object getRaw() {
|
||||
return this;
|
||||
}
|
||||
|
@@ -1,8 +1,5 @@
|
||||
package cn.hutool.json;
|
||||
|
||||
import cn.hutool.json.JSON;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.hutool.json.serialize.JSONDeserializer;
|
||||
import cn.hutool.json.serialize.JSONObjectSerializer;
|
||||
import lombok.Data;
|
||||
@@ -39,14 +36,14 @@ public class Issue2555Test {
|
||||
|
||||
public static class MySerializer implements JSONObjectSerializer<MyType> {
|
||||
@Override
|
||||
public void serialize(JSONObject json, MyType bean) {
|
||||
public void serialize(final JSONObject json, final MyType bean) {
|
||||
json.set("addr", bean.getAddress());
|
||||
}
|
||||
}
|
||||
|
||||
public static class MyDeserializer implements JSONDeserializer<MyType> {
|
||||
@Override
|
||||
public MyType deserialize(JSON json) {
|
||||
public MyType deserialize(final JSON json) {
|
||||
final MyType myType = new MyType();
|
||||
myType.setAddress(((JSONObject)json).getStr("addr"));
|
||||
return myType;
|
||||
|
Reference in New Issue
Block a user