本文整理匯總了Java中org.json.simple.JSONObject.toString方法的典型用法代碼示例。如果您正苦於以下問題:Java JSONObject.toString方法的具體用法?Java JSONObject.toString怎麽用?Java JSONObject.toString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.json.simple.JSONObject
的用法示例。
在下文中一共展示了JSONObject.toString方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createRemascConfig
import org.json.simple.JSONObject; //導入方法依賴的package包/類
public RemascConfig createRemascConfig(String config) {
RemascConfig remascConfig;
try (InputStream is = RemascConfigFactory.class.getClassLoader()
.getResourceAsStream(this.configPath); InputStreamReader fileReader = new InputStreamReader(is)){
JSONParser parser = new JSONParser();
JSONObject jsonObject = (JSONObject) parser.parse(fileReader);
JSONObject jsonConfig = (JSONObject) jsonObject.get(config);
String remascString = jsonConfig.toString();
remascConfig = mapper.readValue(remascString, RemascConfig.class);
} catch (Exception ex) {
logger.error("Error reading REMASC configuration[{}]: {}", config, ex);
throw new RemascException("Error reading REMASC configuration[" + config +"]: ", ex);
}
return remascConfig;
}
示例2: addAttachment
import org.json.simple.JSONObject; //導入方法依賴的package包/類
public static String addAttachment(int eid, File toattach,
JIRAHttpClient client) {
String sr = "";
try {
URL projListUrl = new URL(client.url.toString() + ZAPI
+ "attachment?entityId=" + eid + "&entityType=EXECUTION");
DLogger.Log("Uploading Attachments with EID ",
projListUrl.toString());
JSONObject res = client.post(projListUrl, toattach);
DLogger.Log("Uploading Attachments with EID,Response ", res);
sr = res.toString();
} catch (Exception ex) {
LOG.log(Level.SEVERE, ex.getMessage(), ex);
}
return sr;
}
示例3: exportToJSONString
import org.json.simple.JSONObject; //導入方法依賴的package包/類
@Override
public String
exportToJSONString()
throws IOException
{
JSONObject obj = new JSONObject();
exportToJSONObject( obj );
return( obj.toString());
}
示例4: buildJson
import org.json.simple.JSONObject; //導入方法依賴的package包/類
public static String buildJson(String username, String message) {
JSONObject json = new JSONObject();
json.put("username", username);
json.put("message", message);
return json.toString();
}
示例5: toMessage
import org.json.simple.JSONObject; //導入方法依賴的package包/類
private static String toMessage(Object data, String action) {
JSONObject msg = new JSONObject();
msg.put("DATA", data);
msg.put("res", action);
return msg.toString();
}
示例6: encodeToJSON
import org.json.simple.JSONObject; //導入方法依賴的package包/類
/**
* Encodes a map into a JSON formatted string.
* <p>
* Handles multiple layers of Maps and Lists. Handls String, Number,
* Boolean, and null values.
*
* @param map Map to change into a JSON formatted string
* @return JSON formatted string
*
* @since 3.0.1.5
*/
public static String encodeToJSON(Map map) {
JSONObject jobj = encodeToJSONObject(map);
StringBuilder sb = new StringBuilder(8192);
jobj.toString( sb );
return( sb.toString());
}