use of com.alibaba.fastjson.JSONObject in project fastjson by alibaba.
the class JSONObjectTest_get_2 method test_get_obj.
public void test_get_obj() throws Exception {
JSONObject obj = new JSONObject();
{
Map<String, Object> value = new HashMap<String, Object>();
value.put("@type", "com.alibaba.json.bvt.JSONObjectTest_get_2$VO");
value.put("id", 1001);
obj.put("value", value);
}
VO value = (VO) obj.getObject("value", Object.class);
Assert.assertEquals(1001, value.getId());
}
use of com.alibaba.fastjson.JSONObject in project fastjson by alibaba.
the class MaterializedInterfaceTest2 method test_parse.
public void test_parse() throws Exception {
String text = "{\"id\":123, \"name\":\"chris\"}";
JSONObject object = JSON.parseObject(text);
Bean bean = TypeUtils.cast(object, Bean.class, null);
Assert.assertEquals(123, bean.getId());
Assert.assertEquals("chris", bean.getName());
String text2 = JSON.toJSONString(bean);
System.out.println(text2);
}
use of com.alibaba.fastjson.JSONObject in project fastjson by alibaba.
the class JSONObjectTest5 method test.
public void test() throws Exception {
JSONObject jsonObject = new JSONObject(3, true);
jsonObject.put("name", "J.K.SAGE");
jsonObject.put("age", 21);
jsonObject.put("msg", "Hello!");
JSONObject cloneObject = (JSONObject) jsonObject.clone();
assertEquals(JSON.toJSONString(jsonObject), JSON.toJSONString(cloneObject));
}
use of com.alibaba.fastjson.JSONObject in project fastjson by alibaba.
the class JSONObjectTest6 method test.
public void test() throws Exception {
JSONObject jsonObject = new JSONObject();
jsonObject.put("value", 123);
Model model = jsonObject.toJavaObject(Model.class);
assertEquals(123, model.value);
}
use of com.alibaba.fastjson.JSONObject in project fastjson by alibaba.
the class Bug_for_gongwenhua method test_0.
public void test_0() throws Exception {
String text = "{\"FH2\\\"\\v \":0,\"alipa9_login\":0,\"alipay_login\":14164,\"durex\":317,\"intl.datasky\":0,\"taobao_refund\":880}";
JSONObject obj = JSONObject.parseObject(text);
Assert.assertNotNull(obj);
Assert.assertEquals(0, obj.get("FH2\" "));
}
Aggregations