use of com.alibaba.fastjson.JSONObject in project fastjson by alibaba.
the class Bug_for_huangchun method test_serialize_url.
public void test_serialize_url() throws Exception {
JSONObject json = new JSONObject();
json.put("info", "<a href=\"http://www.baidu.com\"> 问题链接 </a> ");
String text = JSON.toJSONString(json);
System.out.println(text);
}
use of com.alibaba.fastjson.JSONObject in project fastjson by alibaba.
the class Bug_for_issue_232 method test_for_issue.
public void test_for_issue() throws Exception {
String source = "{\"code\": 0, \"data\": {\"country\": \"China\", \"country_id\": \"CN\", \"area\": \"East China\", \"area_id\": \"300000\", \"region\": \"Jiangsu Province \",\" region_id \":\" 320000 \",\" city \":\" Nanjing \",\" city_id \":\" 320100 \",\" county \":\" \",\" county_id \":\" - 1 \",\" isp \":\" China Unicom \",\" isp_id \":\" 100026 \",\" ip \":\" 58.240.65.50 \"}}";
JSONObject object = JSONObject.parseObject(source);
Assert.assertEquals(0, object.getIntValue("code"));
}
use of com.alibaba.fastjson.JSONObject in project fastjson by alibaba.
the class Bug_for_issue_296 method test_for_issue_127.
public void test_for_issue_127() throws Exception {
String text = "{\"downloadSpeed\":631055}";
JSONObject obj = (JSONObject) JSON.parse(text);
Assert.assertEquals(631055, obj.get("downloadSpeed"));
}
use of com.alibaba.fastjson.JSONObject in project fastjson by alibaba.
the class Bug_127_for_qiuyan81 method test_parserUndefined_comma.
public void test_parserUndefined_comma() {
String jsonString = "{PayStatus:0,RunEmpId:undefined,ext:1001}";
JSONObject json = (JSONObject) JSON.parse(jsonString);
Assert.assertEquals(1001, json.get("ext"));
Assert.assertEquals(0, json.get("PayStatus"));
Assert.assertEquals(3, json.size());
}
use of com.alibaba.fastjson.JSONObject in project fastjson by alibaba.
the class Bug_for_JSONObject method test_0.
public void test_0() throws Exception {
JSONSerializer ser = new JSONSerializer();
ser.config(SerializerFeature.WriteClassName, true);
ser.write(new JSONObject());
}
Aggregations