map.putDefault("a", 3);
assertEquals(2, map.get("a").asInt());
}
public void testEqualsTo() {
Json a = map();
Json b = map();
assertTrue(a.equalsTo(b));
a = list();
b = list();
assertTrue(a.equalsTo(b));
a = list("foo", "bar");
b = list("foo", "bar");
assertTrue(a.equalsTo(b));
a = map().put("foo", "bar");
b = map().put("foo", "bar");
assertTrue(a.equalsTo(b));
a = map().put("foo", list("bar"));
b = map().put("foo", list("bar"));
assertTrue(a.equalsTo(b));
a = map();
b = sortedMap();
assertTrue(a.equalsTo(b));
a = new Json(true);
b = new Json(true);
assertTrue(a.equalsTo(b));
a = new Json(1);
b = new Json(1l);
assertTrue(a.equalsTo(b));
a = new Json(1.0);
b = new Json(1l);
assertTrue(a.equalsTo(b));
a = new Json(null);
b = new Json(null);
assertTrue(a.equalsTo(b));
a = map();
b = list();
assertFalse(a.equalsTo(b));
a = list();
b = map();
assertFalse(a.equalsTo(b));
a = list(1, 2, 3, 4);
b = list(1, 2, 3);
assertFalse(a.equalsTo(b));
a = map().put("foo", 1);
b = map().put("bar", 1);
assertFalse(a.equalsTo(b));
a = new Json(1);
b = new Json(null);
assertFalse(a.equalsTo(b));
a = list(1, 3);
b = list(1, 2);
assertFalse(a.equalsTo(b));