add emptyIfNull

This commit is contained in:
Looly
2019-08-21 16:12:06 +08:00
parent d5076d9b33
commit 2f2c9e58d2
5 changed files with 103 additions and 55 deletions

View File

@@ -15,7 +15,7 @@ import cn.hutool.json.test.bean.UserA;
import cn.hutool.json.test.bean.UserC;
public class JSONUtilTest {
@Test
public void toJsonStrTest() {
UserA a1 = new UserA();
@@ -47,7 +47,7 @@ public class JSONUtilTest {
data.put("model2", model);
JSONObject jsonObject = JSONUtil.parseObj(data);
Assert.assertTrue(jsonObject.containsKey("model"));
Assert.assertEquals(1, jsonObject.getJSONObject("model").getInt("type").intValue());
Assert.assertEquals("17610836523", jsonObject.getJSONObject("model").getStr("mobile"));
@@ -94,7 +94,7 @@ public class JSONUtilTest {
JSONObject propJson = JSONUtil.parseObj(prop);
Assert.assertEquals("", propJson.getStr("gender"));
Assert.assertEquals(18, propJson.getInt("age").intValue());
// Assert.assertEquals("{\"age\":18,\"gender\":\"男\"}", user.getProp());
// Assert.assertEquals("{\"age\":18,\"gender\":\"男\"}", user.getProp());
}
@Test
@@ -117,7 +117,7 @@ public class JSONUtilTest {
JSONObject jsonObject = JSONUtil.parseObj(html);
Assert.assertEquals("Something\\u00a0must\\u00a0have\\u00a0been\\u00a0changed\\u00a0since\\u00a0you\\u00a0leave", jsonObject.getStrEscaped("name"));
}
@Test
public void parseFromXmlTest() {
String s = "<sfzh>640102197312070614</sfzh><sfz>640102197312070614X</sfz><name>aa</name><gender>1</gender>";