Java Code Examples for com.alibaba.fastjson.JSONObject#toString()

The following examples show how to use com.alibaba.fastjson.JSONObject#toString() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: webrtc_android   File: DWebSocket.java    License: MIT License 6 votes vote down vote up
/**
 * ------------------------------发送消息----------------------------------------
 */
public void createRoom(String room, int roomSize, String myId) {
    Map<String, Object> map = new HashMap<>();
    map.put("eventName", "__create");

    Map<String, Object> childMap = new HashMap<>();
    childMap.put("room", room);
    childMap.put("roomSize", roomSize);
    childMap.put("userID", myId);

    map.put("data", childMap);
    JSONObject object = new JSONObject(map);
    final String jsonString = object.toString();
    Log.d(TAG, "send-->" + jsonString);
    send(jsonString);
}
 
Example 2
Source Project: boot-actuator   File: DESUtil.java    License: MIT License 6 votes vote down vote up
public static void main(String[] args) {
	String secretKey = "[email protected][email protected]#$250";  
	String iv = "88888888"; 
	JSONObject param=new JSONObject();
 	    param.put("num", "10");
 	    param.put("content", "修复故障");
    String data = param.toString();
    
	// 加密数据
	try {
		System.out.println(encode(data, secretKey, iv));
		System.out.println(decode(encode(data, secretKey, iv), secretKey, iv));
	} catch (Exception e) {
		e.printStackTrace();
	}
	
	
}
 
Example 3
Source Project: MicroCommunity   File: StartException.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 异常
 * @return
 */
public String toJsonString() {
    JSONObject exceptionJson = JSONObject.parseObject("{\"exception\":{}");
    JSONObject exceptionJsonObj = exceptionJson.getJSONObject("exception");

    if (getResult() != null)
        exceptionJsonObj.putAll(JSONObject.parseObject(result.toString()));

    exceptionJsonObj.put("exceptionTrace",getMessage());

    return exceptionJsonObj.toString();
}
 
Example 4
Source Project: MicroCommunity   File: ProtocolUtil.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 创建公用输出
 *  Controller返回 html 协议
 * {'RESULT_CODE':'1999','RESULT_MSG':'失败原因','RESULT_INFO':{...}}
 * @return
 */
public static String createResultMsg(String resultCode, String resultMsg, JSONObject resultInfo) {
    JSONObject data = new JSONObject();
    data.put(RESULT_CODE, resultCode);
    data.put(RESULT_MSG, resultMsg);
    data.put(RESULT_INFO, resultInfo);
    return data.toString();
}
 
Example 5
/**
 * 异常
 * @return
 */
public String toJsonString() {
    JSONObject exceptionJson = JSONObject.parseObject("{\"exception\":{}");
    JSONObject exceptionJsonObj = exceptionJson.getJSONObject("exception");

    if (getResult() != null)
        exceptionJsonObj.putAll(JSONObject.parseObject(result.toString()));

    exceptionJsonObj.put("exceptionTrace",getMessage());

    return exceptionJsonObj.toString();
}
 
Example 6
Source Project: MicroCommunity   File: SMOException.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 异常
 * @return
 */
public String toJsonString() {
    JSONObject exceptionJson = JSONObject.parseObject("{\"exception\":{}");
    JSONObject exceptionJsonObj = exceptionJson.getJSONObject("exception");

    if (getResult() != null)
        exceptionJsonObj.putAll(JSONObject.parseObject(result.toString()));

    exceptionJsonObj.put("exceptionTrace",getMessage());

    return exceptionJsonObj.toString();
}
 
Example 7
Source Project: PeonyFramwork   File: StatisticsSevlet.java    License: Apache License 2.0 5 votes vote down vote up
@Override
    public void init() throws ServletException{
        statisticsService = BeanHelper.getServiceBean(StatisticsService.class);
        Map<String,String> map = statisticsService.getTabMap();
        JSONObject jsonObject = new JSONObject();
        // 加个排序
//        tabList.sort();
        //
        //
        for(Map.Entry<String,String> entry : map.entrySet()){
            jsonObject.put(entry.getKey(),entry.getValue());
        }
        tabJson = jsonObject.toString();
        log.info("init gmServlet finish");
    }
 
Example 8
Source Project: MicroCommunity   File: OrdersException.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 异常
 * @return
 */
public String toJsonString() {
    JSONObject exceptionJson = JSONObject.parseObject("{\"exception\":{}");
    JSONObject exceptionJsonObj = exceptionJson.getJSONObject("exception");

    if (getResult() != null)
        exceptionJsonObj.putAll(JSONObject.parseObject(result.toString()));

    exceptionJsonObj.put("exceptionTrace",getMessage());

    return exceptionJsonObj.toString();
}
 
Example 9
Source Project: MicroCommunity   File: RuleException.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 异常
 * @return
 */
public String toJsonString() {
    JSONObject exceptionJson = JSONObject.parseObject("{\"exception\":{}");
    JSONObject exceptionJsonObj = exceptionJson.getJSONObject("exception");

    if (getResult() != null)
        exceptionJsonObj.putAll(JSONObject.parseObject(result.toString()));

    exceptionJsonObj.put("exceptionTrace",getMessage());

    return exceptionJsonObj.toString();
}
 
Example 10
Source Project: redis-manager   File: HttpClientUtil.java    License: Apache License 2.0 5 votes vote down vote up
private static HttpPut putForm(String url, JSONObject data) {
    HttpPut httpPut = new HttpPut(url);
    httpPut.setHeader(CONNECTION, KEEP_ALIVE);
    httpPut.setHeader(CONTENT_TYPE, APPLICATION_JSON);
    StringEntity entity = new StringEntity(data.toString(), UTF8);//解决中文乱码问题
    httpPut.setEntity(entity);
    return httpPut;
}
 
Example 11
Source Project: webrtc_android   File: DWebSocket.java    License: MIT License 5 votes vote down vote up
public void sendOffer(String myId, String userId, String sdp) {
    Map<String, Object> map = new HashMap<>();
    Map<String, Object> childMap = new HashMap<>();
    childMap.put("sdp", sdp);
    childMap.put("userID", userId);
    childMap.put("fromID", myId);
    map.put("data", childMap);
    map.put("eventName", "__offer");
    JSONObject object = new JSONObject(map);
    final String jsonString = object.toString();
    Log.d(TAG, "send-->" + jsonString);
    send(jsonString);
}
 
Example 12
Source Project: webrtc_android   File: DWebSocket.java    License: MIT License 5 votes vote down vote up
public void sendAnswer(String myId, String userId, String sdp) {
    Map<String, Object> map = new HashMap<>();
    Map<String, Object> childMap = new HashMap<>();
    childMap.put("sdp", sdp);
    childMap.put("fromID", myId);
    childMap.put("userID", userId);
    map.put("data", childMap);
    map.put("eventName", "__answer");
    JSONObject object = new JSONObject(map);
    final String jsonString = object.toString();
    Log.d(TAG, "send-->" + jsonString);
    send(jsonString);
}
 
Example 13
Source Project: redis-manager   File: HttpClientUtil.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @param url
 * @param data
 * @return
 */
private static HttpPost postForm(String url, JSONObject data, HttpHost httpHost) {
    HttpPost httpPost = new HttpPost(url);
    httpPost.setConfig(getRequestConfig(httpHost));
    httpPost.setHeader(CONNECTION, KEEP_ALIVE);
    httpPost.setHeader(CONTENT_TYPE, APPLICATION_JSON);
    httpPost.setHeader(ACCEPT, APPLICATION_JSON);
    StringEntity entity = new StringEntity(data.toString(), UTF8);
    httpPost.setEntity(entity);
    return httpPost;
}
 
Example 14
/**
 * 获取用例调试日志
 * @param projectCaseDebug 调试用例对象
 * @author Seagull
 * @date 2019年3月14日
 */
@RequiresPermissions("testmanagmt:projectCase:edit")
@PostMapping("/refreshDebugLog")
@ResponseBody
public String refreshDebugLog(ProjectCaseDebug projectCaseDebug)
{
	JSONObject json = new JSONObject();
	/*调试结束标识 0 进行中 1结束 2异常*/
	String status="0";
	String ms;
	try {
		List<ProjectCaseDebug> logList=projectCaseDebugService.selectProjectCaseDebugList(projectCaseDebug);
		StringBuilder stringBuilder = new StringBuilder();
		for(ProjectCaseDebug log:logList){
			stringBuilder.append(log.getLogLevel()).append(": ").append(log.getLogDetail()).append("</br>");
			status=log.getDebugIsend().toString();
		}
		ms=stringBuilder.toString();
		
		json.put("status", status);
		json.put("ms", ms);
		return json.toString();
		
	} catch (Exception e) {
		e.printStackTrace();
		json.put("status", "2");
		json.put("ms", "获取调试日志出现异常!");
		return json.toString();
	}
	
}
 
Example 15
/**
 * 异常
 * @return
 */
public String toJsonString() {
    JSONObject exceptionJson = JSONObject.parseObject("{\"exception\":{}");
    JSONObject exceptionJsonObj = exceptionJson.getJSONObject("exception");

    if (getResult() != null)
        exceptionJsonObj.putAll(JSONObject.parseObject(result.toString()));

    exceptionJsonObj.put("exceptionTrace",getMessage());

    return exceptionJsonObj.toString();
}
 
Example 16
/**
 * 异常
 * @return
 */
public String toJsonString() {
    JSONObject exceptionJson = JSONObject.parseObject("{\"exception\":{}");
    JSONObject exceptionJsonObj = exceptionJson.getJSONObject("exception");

    if (getResult() != null)
        exceptionJsonObj.putAll(JSONObject.parseObject(result.toString()));

    exceptionJsonObj.put("exceptionTrace",getMessage());

    return exceptionJsonObj.toString();
}
 
Example 17
Source Project: MicroCommunity   File: DAOException.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 异常
 * @return
 */
public String toJsonString() {
    JSONObject exceptionJson = JSONObject.parseObject("{\"exception\":{}");
    JSONObject exceptionJsonObj = exceptionJson.getJSONObject("exception");

    if (getResult() != null)
        exceptionJsonObj.putAll(JSONObject.parseObject(result.toString()));

    exceptionJsonObj.put("exceptionTrace",getMessage());

    return exceptionJsonObj.toString();
}
 
Example 18
/**
 * 异常
 * @return
 */
public String toJsonString() {
    JSONObject exceptionJson = JSONObject.parseObject("{\"exception\":{}");
    JSONObject exceptionJsonObj = exceptionJson.getJSONObject("exception");

    if (getResult() != null)
        exceptionJsonObj.putAll(JSONObject.parseObject(result.toString()));

    exceptionJsonObj.put("exceptionTrace",getMessage());

    return exceptionJsonObj.toString();
}
 
Example 19
/**
 * Ajax前台获取操作字典
 * @param stepType 步骤类型
 * @return 返回步骤类型集合
 * @author Seagull
 * @date 2019年3月12日
 */
   @GetMapping("/getDictDataListByStepType/{stepType}")
   @ResponseBody
public String getDictDataListByStepType(@PathVariable("stepType") Integer stepType) {
	String str = "{\"message\": \"\",\"value\": ,\"code\": 200,\"redirect\": \"\" }";
	try {
		JSONObject json;
		DictData dictData=new DictData();
		if(stepType==0){
			dictData.setDictType("testmanagmt_casestep_httpoperation");
		}else if(stepType==1){
			dictData.setDictType("testmanagmt_casestep_uioperation");
		}else if(stepType==3){
			dictData.setDictType("testmanagmt_casestep_muioperation");
		}else{
			dictData.setDictType("9999999999999999999999999999999999");
		}
		List<DictData> ddlist = dictDataService.selectDictDataList(dictData);
		JSONArray jsonarr = new JSONArray();
		for(DictData obdd:ddlist){
			JSONObject jo = new JSONObject();
               jo.put("name", obdd.getDictValue());
               jo.put("description", obdd.getRemark());
               jsonarr.add(jo);
		}
		String recordJson = jsonarr.toString();
				
		json = JSONObject.parseObject("{\"message\": \"\",\"value\": "+recordJson+",\"code\": 200,\"redirect\": \"\" }");
		str=json.toString();
	} catch (Exception e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	return str;
}
 
Example 20
Source Project: efo   File: ConfigServiceImpl.java    License: MIT License 5 votes vote down vote up
@Override
public String getGlobalConfig() {
    JSONObject jsonObject = (JSONObject) EfoApplication.settings.getObjectUseEval(ConfigConsts
            .GLOBAL_OF_SETTINGS).clone();
    jsonObject.remove(ConfigConsts.UPLOAD_PATH_OF_GLOBAL);
    jsonObject.remove(ConfigConsts.TOKEN_PATH_OF_GLOBAL);
    jsonObject.remove(ConfigConsts.UPLOAD_FORM_OF_SETTING);
    return jsonObject.toString();
}