List of usage examples for org.json JSONObject write
public Writer write(Writer writer) throws JSONException
From source file:org.elfinder.servlets.AbstractConnectorServlet.java
protected static void output(HttpServletResponse response, boolean isResponseTextHtml, JSONObject json, PrintWriter responseWriter) { // encoding was already set by servlet if (isResponseTextHtml) { response.setContentType("text/html; charset=UTF-8"); } else {/* ww w . ja v a2s.co m*/ response.setContentType("application/json; charset=UTF-8"); } try { json.write(responseWriter); } catch (Exception e) { logger.error("", e); } AbstractCommand.closeWriter(responseWriter); }
From source file:org.hypertopic.RESTDatabase.java
protected static void writeBody(HttpURLConnection connection, JSONObject object) throws Exception { connection.setDoOutput(true);/*from w w w . jav a2s . c o m*/ OutputStreamWriter writer = new OutputStreamWriter(connection.getOutputStream(), "UTF-8"); object.write(writer); writer.close(); }