This commit is contained in:
Looly
2020-04-07 11:19:46 +08:00
parent cf5ff51a56
commit d8baf83474
11 changed files with 124 additions and 100 deletions

View File

@@ -189,9 +189,8 @@ public class JSONObjectTest {
public void toBeanTest3() {
String jsonStr = "{'data':{'userName':'ak','password': null}}";
UserWithMap user = JSONUtil.toBean(JSONUtil.parseObj(jsonStr), UserWithMap.class);
String password = user.getData().get("password");
Assert.assertTrue(user.getData().containsKey("password"));
Assert.assertNull(password);
// Bean默认忽略null
Assert.assertFalse(user.getData().containsKey("password"));
}
@Test

View File

@@ -1,15 +1,10 @@
package cn.hutool.json.test.bean;
import lombok.Data;
import java.util.Map;
@Data
public class UserWithMap {
private Map<String, String> data;
public Map<String, String> getData() {
return data;
}
public void setData(Map<String, String> data) {
this.data = data;
}
}