Package com.alibaba.fastjson

Examples of com.alibaba.fastjson.JSONObject.toJSONString()


    PushNotificationMessage pnm = new PushNotificationMessage();
    pnm.setAddTime(CTCommon.getNowTime());
    pnm.setTitle(title);
    pnm.setMessage(message);
    if (null != rowdata)
      pnm.setRowdata(rowdata.toJSONString());
    pnm_service.add(pnm);

    retJson = new JSONObject();
    retJson.put("messageID", pnm.getEncodedKey());
    for (CarPhoneRelation o : cpr_list) {
View Full Code Here


    PushNotificationMessage pnm = new PushNotificationMessage();
    pnm.setAddTime(CTCommon.getNowTime());
    pnm.setTitle(title);
    pnm.setMessage(message);
    if (null != rowdata)
      pnm.setRowdata(rowdata.toJSONString());
    pnm_service.add(pnm);

    retJson = new JSONObject();
    retJson.put("messageID", pnm.getEncodedKey());
    for (CarPhoneRelation o : cpr_list) {
View Full Code Here

    }

    public void test_exception() throws Exception {
        JSONObject object = (JSONObject) JSON.toJSON(new RuntimeException());
        object.put("class", "xxx");
        Assert.assertEquals(Exception.class, JSON.parseObject(object.toJSONString(), Exception.class).getClass());
    }

    public static class Entity {

    }
View Full Code Here

        JSONObject jsonObject = new JSONObject();
        jsonObject.put("name", "Jobs");
        jsonObject.put("age", 50);
        jsonObject.put("salary", new BigDecimal(8000));

        String text = jsonObject.toJSONString();
        System.out.println(text);
    }
}
View Full Code Here

public class JSONParseTest extends TestCase {

    public void test_0() throws Exception {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("scheduleAlarmRules", new ArrayList());
        String jsonString = jsonObject.toJSONString();
        String text = "{\"scheduleAlarmRules\":[]}";
        Object jsonValue = JSON.parse(text);
        System.out.println(jsonValue);
    }
View Full Code Here

        RuntimeException ex = new RuntimeException();
        JSONObject object = (JSONObject) JSON.toJSON(ex);
        JSONArray array = object.getJSONArray("stackTrace");
        array.getJSONObject(0).put("lineNumber", null);
       
        JSON.parseObject(object.toJSONString(), Exception.class);
    }

    public static enum Type {
        A, B, C
    }
View Full Code Here

    JSONObject obj = new JSONObject();
    obj.put("success", this.isSuccess());
    obj.put("msg", this.getMsg());
    obj.put("obj", this.obj);
    obj.put("attributes", this.attributes);
    return obj.toJSONString();
  }
}
View Full Code Here

        RuntimeException ex = new RuntimeException();
        JSONObject object = (JSONObject) JSON.toJSON(ex);
        JSONArray array = object.getJSONArray("stackTrace");
        array.getJSONObject(0).put("lineNumber", null);
       
        JSON.parseObject(object.toJSONString(), Exception.class);
    }

    public static enum Type {
        A, B, C
    }
View Full Code Here

    }

    public void test_exception() throws Exception {
        JSONObject object = (JSONObject) JSON.toJSON(new RuntimeException());
        object.put("class", "xxx");
        Assert.assertEquals(Exception.class, JSON.parseObject(object.toJSONString(), Exception.class).getClass());
    }

    public static class Entity {

    }
View Full Code Here

public class Issue157 extends TestCase {
    public void test_for_issue() throws Exception {
        String m = "2、95开头靓号,呼出显号,对方可以打回,即使不在线亦可设置呼转手机,不错过任何重要电话,不暴露真实身份。\r\n3、应用内完全免费发送文字消息、语音对讲。\r\n4、建议WIFI 或 3G 环境下使用以获得最佳通话体验";
        JSONObject json = new JSONObject();
        json.put("介绍", m);
        String content = json.toJSONString();
        System.out.println(content);
    }
}
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.