use of com.alibaba.fastjson.JSONObject in project fastjson by alibaba.
the class JSONObjectTest method test_getLong_1.
public void test_getLong_1() throws Exception {
JSONObject json = new JSONObject(false);
json.put("A", 55L);
json.put("B", 55);
Assert.assertEquals(json.getLong("A").longValue(), 55L);
Assert.assertEquals(json.getLong("B").longValue(), 55L);
Assert.assertEquals(json.getLong("C"), null);
}
use of com.alibaba.fastjson.JSONObject in project fastjson by alibaba.
the class JSONObjectTest method test_getBoolean.
public void test_getBoolean() throws Exception {
JSONObject json = new JSONObject();
json.put("A", true);
Assert.assertEquals(json.getBoolean("A").booleanValue(), true);
Assert.assertEquals(json.getLong("C"), null);
}
use of com.alibaba.fastjson.JSONObject in project fastjson by alibaba.
the class JSONObjectTest method test_getLong.
public void test_getLong() throws Exception {
JSONObject json = new JSONObject(true);
json.put("A", 55L);
json.put("B", 55);
json.put("K", true);
Assert.assertEquals(json.getLong("A").longValue(), 55L);
Assert.assertEquals(json.getLong("B").longValue(), 55L);
Assert.assertEquals(json.getLong("C"), null);
Assert.assertEquals(json.getBooleanValue("K"), true);
Assert.assertEquals(json.getBoolean("K"), Boolean.TRUE);
}
use of com.alibaba.fastjson.JSONObject in project fastjson by alibaba.
the class JSONObjectTest method test_getDate.
public void test_getDate() throws Exception {
long currentTimeMillis = System.currentTimeMillis();
JSONObject json = new JSONObject();
json.put("A", new Date(currentTimeMillis));
json.put("B", currentTimeMillis);
Assert.assertEquals(json.getDate("A").getTime(), currentTimeMillis);
Assert.assertEquals(json.getDate("B").getTime(), currentTimeMillis);
Assert.assertEquals(json.getLong("C"), null);
}
use of com.alibaba.fastjson.JSONObject in project fastjson by alibaba.
the class JSONObjectTest method test_getObject.
public void test_getObject() throws Exception {
JSONObject json = new JSONObject();
json.put("obj", new JSONObject());
Assert.assertEquals(0, json.getJSONObject("obj").size());
}
Aggregations