mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
add emptyIfNull
This commit is contained in:
@@ -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>";
|
||||
|
Reference in New Issue
Block a user