Search in sources :

Example 61 with JSONObject

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);
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject)

Example 62 with JSONObject

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"));
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject)

Example 63 with JSONObject

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"));
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject)

Example 64 with JSONObject

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());
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject)

Example 65 with JSONObject

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());
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) JSONSerializer(com.alibaba.fastjson.serializer.JSONSerializer)

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