This commit is contained in:
Looly
2022-06-20 18:52:19 +08:00
parent 1a0d7b51a7
commit 270bec0f37
5 changed files with 55 additions and 42 deletions

View File

@@ -1,10 +1,11 @@
package cn.hutool.json;
import cn.hutool.json.serialize.JSONDeserializer;
import lombok.Data;
import org.junit.Assert;
import org.junit.Test;
public class JSONBeanParserTest {
public class JSONDeserializerTest {
@Test
public void parseTest(){
@@ -16,15 +17,17 @@ public class JSONBeanParserTest {
}
@Data
static class TestBean implements JSONBeanParser<JSONObject>{
static class TestBean implements JSONDeserializer<Object> {
private String name;
private String address;
@Override
public void parse(final JSONObject value) {
this.name = value.getStr("customName");
this.address = value.getStr("customAddress");
public Object deserialize(final JSON value) {
final JSONObject valueObj = (JSONObject) value;
this.name = valueObj.getStr("customName");
this.address = valueObj.getStr("customAddress");
return this;
}
}
}