Search in sources :

Example 51 with JSONObject

use of com.alibaba.fastjson.JSONObject in project fastjson by alibaba.

the class JSONObjectTest_get method test_get.

public void test_get() throws Exception {
    JSONObject obj = JSON.parseObject("{id:123}");
    Assert.assertEquals(123, obj.getObject("id", Object.class));
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) JSONObject(com.alibaba.fastjson.JSONObject)

Example 52 with JSONObject

use of com.alibaba.fastjson.JSONObject in project fastjson by alibaba.

the class JSONObjectTest_getDate method test_get_empty.

public void test_get_empty() throws Exception {
    JSONObject obj = new JSONObject();
    obj.put("value", "");
    Assert.assertEquals("", obj.get("value"));
    Assert.assertNull(obj.getDate("value"));
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject)

Example 53 with JSONObject

use of com.alibaba.fastjson.JSONObject in project fastjson by alibaba.

the class JSONObjectTest_getObj method test_get_empty.

public void test_get_empty() throws Exception {
    JSONObject obj = new JSONObject();
    obj.put("value", "");
    Assert.assertEquals("", obj.get("value"));
    Assert.assertNull(obj.getObject("value", Model.class));
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject)

Example 54 with JSONObject

use of com.alibaba.fastjson.JSONObject in project fastjson by alibaba.

the class JSONObjectTest_getObj method test_get_null.

public void test_get_null() throws Exception {
    JSONObject obj = new JSONObject();
    obj.put("value", "null");
    Assert.assertEquals("null", obj.get("value"));
    Assert.assertNull(obj.getObject("value", Model.class));
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject)

Example 55 with JSONObject

use of com.alibaba.fastjson.JSONObject in project fastjson by alibaba.

the class JSONObjectTest_getObj_2 method test_get_empty.

public void test_get_empty() throws Exception {
    JSONObject obj = new JSONObject();
    obj.put("value", "");
    Assert.assertEquals("", obj.get("value"));
    Assert.assertNull(obj.getObject("value", Model.class));
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject)

Aggregations

JSONObject (com.alibaba.fastjson.JSONObject)374 JSONArray (com.alibaba.fastjson.JSONArray)37 Test (org.junit.Test)32 DefaultJSONParser (com.alibaba.fastjson.parser.DefaultJSONParser)23 HashMap (java.util.HashMap)20 JSONException (com.alibaba.fastjson.JSONException)18 ArrayList (java.util.ArrayList)18 Date (java.util.Date)18 JSONReaderScanner (com.alibaba.fastjson.parser.JSONReaderScanner)14 IOException (java.io.IOException)12 Map (java.util.Map)12 WXSDKInstanceTest (com.taobao.weex.WXSDKInstanceTest)11 JSMethod (com.taobao.weex.annotation.JSMethod)11 WXBridgeManagerTest (com.taobao.weex.bridge.WXBridgeManagerTest)9 BigDecimal (java.math.BigDecimal)9 List (java.util.List)9 ValueStack (com.roof.chain.api.ValueStack)7 GenericValueStack (com.roof.chain.support.GenericValueStack)7 Gson (com.google.gson.Gson)6 BigInteger (java.math.BigInteger)5