List of usage examples for org.json.simple JSONObject JSONObject
JSONObject
From source file:JavaCloud.Models.Image.java
public void upload_data(String data, long offset) throws CoreException { JSONObject object = new JSONObject(); object.put("token", token); object.put("image_id", id); object.put("offset", offset); object.put("data", data); Utils.request(address, "/api/image/upload_data/", object); }
From source file:com.saludtec.web.EvolucionComentariosWeb.java
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); try (PrintWriter out = response.getWriter()) { String servicio = request.getRequestURI().replace("/HCEMed/EvolucionComentarios/", ""); switch (servicio) { case "guardar": guardarEvolucionComentario(request).writeJSONString(out); break; case "listar": listarEvolucionComentario(request).writeJSONString(out); break; default://from w w w. j a v a 2 s . c o m obj = new JSONObject(); objArray = new JSONArray(); obj.put("error", "404 - El servicio " + servicio + " no existe"); objArray.add(obj); objArray.writeJSONString(out); break; } } }
From source file:control.UsuariosServlets.EliminarUsuarios.java
/** * Handles the HTTP <code>POST</code> method. * * @param request servlet request/*from w w w . j ava2s . c o m*/ * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { //Obtenemos los paramtros enviados int codigo = Integer.parseInt(request.getParameter("codigo")); JSONObject respError = new JSONObject(); // uno significa que no hay error //Obtenemos La informacion del manager Usuarios manager = new Usuarios(); try { //Almacenamos el error que pueda resultar respError = manager.Eliminar(codigo); //Armamos la respuesta JSON y la enviamos response.setContentType("application/json"); response.getWriter().write(respError.toString()); } catch (Exception ex) { respError.put("error", 0); //Armamos la respuesta JSON y la enviamos response.setContentType("application/json"); response.getWriter().write(respError.toString()); } }
From source file:io.personium.test.jersey.cell.ctl.CellCtlUtils.java
/** * ????????Relation??.//ww w.jav a 2 s .co m * @param cellName ?? * @param testRelationName ?? * @return ? */ @SuppressWarnings("unchecked") public static TResponse createRelation(String cellName, String testRelationName) { JSONObject body = new JSONObject(); body.put("Name", testRelationName); body.put("_Box.Name", null); return Http.request("relation-create.txt").with("token", AbstractCase.BEARER_MASTER_TOKEN) .with("cellPath", cellName).with("body", body.toString()).returns() .statusCode(HttpStatus.SC_CREATED); }
From source file:com.fujitsu.dc.core.rs.StatusResource.java
/** * GET???./* w w w . j a va2s. c o m*/ * @return JAS-RS Response */ @SuppressWarnings("unchecked") @GET @Produces("application/json") public Response get() { StringBuilder sb = new StringBuilder(); // Properties props = DcCoreConfig.getProperties(); JSONObject responseJson = new JSONObject(); JSONObject propertiesJson = new JSONObject(); for (String key : props.stringPropertyNames()) { String value = props.getProperty(key); propertiesJson.put(key, value); } responseJson.put("properties", propertiesJson); // Cell?/ //responseJson.put("service", checkServiceStatus()); // Ads?? responseJson.put("ads", checkAds()); // ElasticSearch Health EsClient client = EsModel.client(); JSONObject esJson = new JSONObject(); esJson.put("health", client.checkHealth()); responseJson.put("ElasticSearch", esJson); sb.append(responseJson.toJSONString()); return Response.status(HttpStatus.SC_OK).entity(sb.toString()).build(); }
From source file:com.conwet.silbops.msg.PublishMsg.java
@Override @SuppressWarnings("unchecked") public JSONObject getPayloadAsJSON() { JSONObject json = new JSONObject(); json.put("notification", notification.toJSON()); json.put("context", context.toJSON()); return json;//from w w w . ja v a 2s .c o m }
From source file:control.ProcesoVertimientosServlets.FinalizarProcesoVertimientos.java
/** * Handles the HTTP <code>POST</code> method. * * @param request servlet request/*from w w w . jav a 2s. c om*/ * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { int codigoProceso = Integer.parseInt(request.getParameter("codigoProceso")); JSONObject respuesta = new JSONObject(); ProcesoVertimientos manager = new ProcesoVertimientos(); respuesta = manager.finalizarProceso(codigoProceso); response.setContentType("application/json"); response.getWriter().write(respuesta.toString()); } catch (Exception ex) { } }
From source file:control.ParametrizacionServlets.ActualizarLaboratorios.java
/** * Handles the HTTP <code>POST</code> method. * * @param request servlet request//www . j av a 2 s.co m * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { JSONObject salida = new JSONObject(); try { String nombre = request.getParameter("nombre"); String direccion = request.getParameter("direccion"); String telefono = request.getParameter("telefono1"); String telefono2 = request.getParameter("telefono2"); String correo = request.getParameter("correo"); String resolucion = request.getParameter("resolucion"); String vigencia = request.getParameter("vigencia"); String contactos = request.getParameter("contactos"); Integer codigo = Integer.parseInt(request.getParameter("codigo")); String paramAcreditados = request.getParameter("paramAcreditados"); Laboratorios manager = new Laboratorios(); manager.actualizar(nombre, contactos, direccion, telefono, telefono2, correo, resolucion, vigencia, codigo); int resp = 0; //Obtenemos La informacion del manager AcreditacionParametros managerAcreditacion = new AcreditacionParametros(); //Eliminamos lo parametros resp = managerAcreditacion.eliminar(codigo); Object obj = JSONValue.parse(paramAcreditados); JSONArray jsonArray = new JSONArray(); jsonArray = (JSONArray) obj; //Recorremos el JSONArray y obtenemos la informacion. for (int i = 0; i < jsonArray.size(); i++) { JSONObject jsonObject = (JSONObject) jsonArray.get(i); int codParametro = Integer.parseInt((String) jsonObject.get("codigoParam")); managerAcreditacion.insertar(codParametro, codigo); } } catch (Exception e) { } }
From source file:com.pjaol.ESB.formatters.JSONFormatter.java
private JSONArray recurseNamedList(NamedList output) { int sz = output.size(); JSONArray jarr = new JSONArray(); for (int i = 0; i < sz; i++) { JSONObject jo = new JSONObject(); String k = output.getName(i); Object v = output.getVal(i); if (v instanceof NamedList) { jo.put(k, recurseNamedList((NamedList) v)); } else if (v instanceof Map) { jo.put(k, recurseMap((Map) v)); } else {/*ww w . j av a 2 s . c om*/ jo.put(k, v); } jarr.add(jo); } return jarr; }
From source file:com.mapr.xml2json.MySaxParser.java
@Override public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { super.startElement(uri, localName, qName, attributes); JSONObject tag = new JSONObject(); JSONArray array = new JSONArray(); int length = attributes.getLength(); for (int i = 0; i < length; i++) { JSONObject temp = new JSONObject(); String qNameVal = attributes.getQName(i); String valueVal = attributes.getValue(i); if (qNameVal != null) qNameVal = cleanQName(qNameVal); if (valueVal.trim().length() > 0) { tag.put(qNameVal, valueVal); //array.add(temp); }/*from w w w. j a v a2 s.com*/ } if (array.size() > 0) tag.put("attributes", array); // tag.put("qName",cleanQName(qName)); //log.info("After clean:" + cleanQName(qName)); stk.push(tag); }