0
根據API,我們應該可以做到這一點。JSONObject.toString類型不匹配不能從JSONString轉換爲JSONObject
http://www.json.org/javadoc/org/json/JSONObject.html#toString()
@Override
public JSONObject buildPayload(BuildData buildData, String jenkinsUrl, List<String> logLines) {
JSONObject payload = new JSONObject();
payload.put("data", buildData.toJson());
payload.put("message", logLines);
payload.put("source", "jenkins");
payload.put("source_host", jenkinsUrl);
payload.put("@timestamp", buildData.getTimestamp());
payload.put("@version", 1);
// we need to flatten payload from JSONObject to String
return payload.toString();
}
顯然,我們定義的有效載荷,這是一個JSONObject。爲什麼這不起作用,應該怎麼辦?
什麼故障,你正好面對? – h7r 2015-02-09 18:52:13