/** * {@inheritDoc} */ @Override public void generateResponse(StaplerRequest req, StaplerResponse rsp, Object node) throws IOException, ServletException { byte[] bytes = jsonObject.toString().getBytes(UTF8); rsp.setContentType("application/json; charset=UTF-8"); rsp.setContentLength(bytes.length); rsp.getOutputStream().write(bytes); } }
private void writeBody(StaplerResponse response, JSONObject body) throws IOException { response.setContentType("application/json"); PrintWriter writer = response.getWriter(); writer.write(body.toString()); writer.flush(); writer.close(); } }
return load(reducedJson.toString(), System.currentTimeMillis());
if (LOGGER.isLoggable(Level.SEVERE)) { LOGGER.severe(msg); LOGGER.severe(json.toString(2));
http.setDoOutput(true); String body = wrappedData.toString(); if (LOGGER.isLoggable(Level.FINEST)) { LOGGER.finest("Submitting JSON: " + body);
@RequestMapping("/hello") public ResponseEntity<?> hello(){ City city = cityMapper.selectByPrimaryKey(12); System.out.println(JSONObject.fromObject(city).toString()); return new ResponseEntity<Object>("hello", HttpStatus.OK); } }
@RequestMapping("/hello") public ResponseEntity<?> hello(){ City city = cityMapper.selectByPrimaryKey(12); System.out.println(JSONObject.fromObject(city).toString()); return new ResponseEntity<Object>("hello", HttpStatus.OK); } }
public String getJavaScript() { final StringBuilder js = new StringBuilder("Hippo.Events.publish('"); js.append(name); js.append("'"); if (!parameters.isEmpty()) { js.append(","); js.append(parameters.toString()); } js.append(");"); return js.toString(); }
public static String getAsJSON(Serializable serializable, JsonConfig jsonConfig) { if (serializable != null) { return JSONObject.fromObject(serializable, jsonConfig).toString(); } else { return "null"; } }
public static String getAsJSON(Serializable serializable, JsonConfig jsonConfig) { if (serializable != null) { return JSONObject.fromObject(serializable, jsonConfig).toString(); } else { return "null"; } }
/** * {@inheritDoc} */ @Override public void generateResponse(StaplerRequest req, StaplerResponse rsp, Object node) throws IOException, ServletException { byte[] bytes = jsonObject.toString().getBytes(UTF8); rsp.setContentType("application/json; charset=UTF-8"); rsp.setContentLength(bytes.length); rsp.getOutputStream().write(bytes); } }
public static String messageAjax(int statusCode, String message, String navTabId) { JSONObject json = new JSONObject(); json.put("statusCode", statusCode); json.put("message", message); json.put("navTabId", navTabId); return json.toString(); }
protected String createFeatureTypeJson(final String featureTypeName) { final JSONObject featTypeJson = new JSONObject(); featTypeJson.put("name", featureTypeName); final JSONObject jsonObj = new JSONObject(); jsonObj.put("featureType", featTypeJson); return jsonObj.toString(); }
public void register(String method, JSONObject response) { server.register( "/api/" + method, TestUtils.makeHttpHandler(HttpStatus.SC_OK, response.toString(2), requestBodies) ); } }
String createJSONBody(String[][] rules) { JSONObject json = new JSONObject(); for (String[] rule : rules) { json.put(rule[0], rule[1]); } return json.toString(1); }
@Override public UpdateLoggingResponse updateLogging(final UpdateLoggingRequest request) throws LogException { Args.notNull(request, "request"); final String project = request.GetProject(); Map<String, String> headers = GetCommonHeadPara(project); final Logging logging = request.getLogging(); ResponseMessage response = SendData(project, HttpMethod.PUT, Consts.LOGGING_URI, Collections.<String, String>emptyMap(), headers, logging.marshal().toString()); return new UpdateLoggingResponse(response.getHeaders()); }
protected ACL ExtractACLFromResponse(JSONObject dict, String requestId) throws LogException { ACL acl = new ACL(); try { acl.FromJsonString(dict.toString()); } catch (LogException e) { throw new LogException(e.GetErrorCode(), e.GetErrorMessage(), e.getCause(), requestId); } return acl; }
public final String getConfigurationAsJSON() { if (getSettings() instanceof YuiObject) { return ((YuiObject) getSettings()).toScript(); } else if (getSettings() != null) { return JSONObject.fromObject(getSettings(), getJsonConfig()).toString(); } else { return "null"; } }
@Test public void testGetCoverageWorkingBackend() throws IOException { JSONObject validJSON = TestUtils.getJSONFromFile(getClass(), "validCoverage"); server.register("/*", TestUtils.makeHttpHandler(HttpStatus.SC_OK, validJSON.toString())); CodeCoverageMetrics metrics = client.getParentCoverage(TestUtils.TEST_SHA); assertEquals(42.0f, metrics.getLineCoveragePercent(), 0.01f); }