use of com.alibaba.fastjson.JSONObject in project fastjson by alibaba.
the class Issue177 method test_for_issue_177.
public void test_for_issue_177() throws Exception {
JSONObject jsonObject = new JSONObject();
jsonObject.put("data", new byte[20]);
String jsonString = JSON.toJSONString(jsonObject);
JSONObject parseObject = JSON.parseObject(jsonString);
byte[] bytes = parseObject.getBytes("data");
byte[] bs = parseObject.getObject("data", byte[].class);
}
use of com.alibaba.fastjson.JSONObject in project fastjson by alibaba.
the class Issue179 method test_for_issue_179.
public void test_for_issue_179() throws Exception {
Student student = new Student();
School school = new School();
school.setStudent(student);
student.setSchool(school);
// String schoolJSONString = JSON.toJSONString(school);
// System.out.println(schoolJSONString);
//
// School fromJSONSchool = JSON.parseObject(schoolJSONString,
// School.class);
//
// System.out.println(JSON.toJSONString(fromJSONSchool));
JSONObject object = new JSONObject();
object.put("school", school);
String jsonString = JSON.toJSONString(object);
System.out.println(jsonString);
JSONObject object2 = (JSONObject) JSON.parseObject(jsonString, JSONObject.class);
System.out.println(JSON.toJSONString(object2));
School school2 = object2.getObject("school", School.class);
System.out.println(school2);
}
use of com.alibaba.fastjson.JSONObject in project fastjson by alibaba.
the class Bug_for_liuying method test_for_bug.
public void test_for_bug() throws Exception {
String aa = "[{\"dictFont\":\"\",\"dictId\":\"wap\",\"dictName\":\"无线&手淘\"},{\"dictFont\":\"\",\"dictId\":\"etao\",\"dictName\":\"搜索\"}]";
JSONObject jsonResult = new JSONObject();
JSONArray jsonArray = JSONArray.parseArray(aa);
jsonResult.put("aaa", jsonArray);
System.out.println(jsonResult);
}
use of com.alibaba.fastjson.JSONObject in project fastjson by alibaba.
the class Bug_for_sanxiao method test_0.
public void test_0() throws Exception {
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("json/Bug_for_sanxiao.json");
String text = IOUtils.toString(is);
is.close();
JSONObject obj = JSON.parseObject(text);
System.out.println(obj);
Assert.assertEquals(obj.getJSONArray("segments").getJSONObject(0), obj.getJSONArray("passengerSegmentItems").getJSONObject(0).get("segment"));
Assert.assertEquals(1428, obj.getJSONArray("passengerSegmentItems").getJSONObject(0).getJSONObject("segment").getIntValue("agentId"));
}
use of com.alibaba.fastjson.JSONObject in project fastjson by alibaba.
the class Bug_for_issue_446 method test_for_issue.
public void test_for_issue() throws Exception {
String text = "{\"amount\":1,\"channel_id\":\"wnys01\",\"gem\":1,\"id\":\"pay\",\"login_name\":\"U10722466A\",\"money\":1000,\"order_id\":\"99142AO10000086695A\",\"pay_channel\":\"weilan\",\"pay_time\":\"2015-11-05 20:59:04\",\"reward\":\"11:5_12:5_13:5,4:1_5:1_6:1\",\"status\":1,\"user_id\":19313}";
JSONObject obj = (JSONObject) JSON.parse(text);
Assert.assertEquals(1, obj.get("amount"));
}
Aggregations