List of usage examples for org.json.simple JSONObject JSONObject
JSONObject
From source file:com.saludtec.web.DescripcionPlanDeTratamientoWeb.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/descripcionPlanDeTratamiento/", ""); switch (servicio) { case "guardar": guardarDescripcionPlanDeTratamiento(request).writeJSONString(out); break; case "listar": listarDescripcionPlanDeTratamiento(request).writeJSONString(out); break; default:// w w w . jav a2 s .com 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:org.kitodo.data.elasticsearch.index.type.BaseType.java
/** * Method for adding id to JSONObject.// w ww. j av a 2s . co m * * @param id * of object * @return JSONObject */ @SuppressWarnings("unchecked") private JSONObject addIdForRelation(Integer id) { JSONObject object = new JSONObject(); object.put("id", id); return object; }
From source file:com.oic.event.GetUserInfo.java
private JSONObject getUserinfo(JSONObject json, long userid, int mapid) throws NullPointerException { MapFactory factory = MapFactory.getInstance(); OicMap map = factory.getMap(mapid);//from w ww .j av a 2s. c o m OicCharacter c = map.getUser(userid); json.put("userid", c.getUserId()); json.put("username", c.getName()); JSONObject posJSON = new JSONObject(); Position pos = c.getPos(); posJSON.put("x", pos.getX()); posJSON.put("y", pos.getX()); posJSON.put("width", pos.getWidth()); posJSON.put("height", pos.getHeight()); json.put("pos", posJSON); json.put("mapid", c.getMapid()); json.put("avatarid", c.getAvatarId()); return json; }
From source file:control.ParametrizacionServlets.InsertarAsociacionContratos.java
/** * Handles the HTTP <code>POST</code> method. * * @param request servlet request/* w w w.j ava2 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 { try { objectErrores = new JSONObject(); arrayErrores = new JSONArray(); //Obtenemos el numero de contrato Double contratoPadre = Double.parseDouble(request.getParameter("contrato")); //Obtenemos la cadena con la informacion y la convertimos en un //JSONArray String puntos = request.getParameter("contratosAsignados"); Object obj = JSONValue.parse(puntos); JSONArray jsonArray = new JSONArray(); jsonArray = (JSONArray) obj; //Recorremos el JSONArray y obtenemos la informacion. for (int i = 0; i < jsonArray.size(); i++) { //Obtenemos el contrato hijo JSONObject jsonObject = (JSONObject) jsonArray.get(i); Double contratoHijo = Double.parseDouble((String) jsonObject.get("contratoAsignado")); //Creamos el manager y guardamos la informacion. AsociacionContratos manager = new AsociacionContratos(); int error = manager.insertar(contratoPadre, contratoHijo); /* Obtenemos la respuesta del procedimiento y Validamos si el contrato padre es valido, si no lo es no registramos nada y enviamos el error. */ if (error == 2) { guardarErrores(error, contratoPadre); escribirJSON(response); break; } else if (error == 4) { //Si el hijo no es valido, registramos el error y //enviamos el listado a la vista al finalizar el for. guardarErrores(error, contratoHijo); } } escribirJSON(response); } catch (Exception ex) { JSONObject respError = new JSONObject(); respError.put("error", 0); arrayErrores.add(respError); escribirJSON(response); } }
From source file:at.uni_salzburg.cs.ckgroup.cscpp.mapper.course.WayPoint.java
@SuppressWarnings("unchecked") @Override//from w w w .jav a 2 s .c o m public String toJSONString() { JSONObject obj = new JSONObject(); obj.put("latitude", Double.valueOf(point.getLatitude())); obj.put("longitude", Double.valueOf(point.getLongitude())); obj.put("altitude", Double.valueOf(point.getAltitude())); obj.put("precision", Double.valueOf(precision)); obj.put("velocity", Double.valueOf(velocity)); return obj.toString(); }
From source file:io.personium.engine.rs.StatusResource.java
/** * GET???./* w w w . ja v a2s.c o m*/ * @return JAS-RS Response */ @SuppressWarnings("unchecked") @GET @Produces("application/json") public Response get() { StringBuilder sb = new StringBuilder(); // Properties props = PersoniumEngineConfig.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); sb.append(responseJson.toJSONString()); return Response.status(HttpStatus.SC_OK).entity(sb.toString()).build(); }
From source file:model.Post_store.java
public static void setlastid(int lastid) { JSONObject obj = new JSONObject(); obj.put("lastid", lastid); try (FileWriter file = new FileWriter(root + "posts/lastid.json");) { file.write(obj.toJSONString());/* w w w . ja va2 s .c om*/ file.flush(); file.close(); } catch (IOException ex) { System.out.println(ex); } }
From source file:com.mobicage.rogerthat.form.GPSLocation.java
@Override @SuppressWarnings("unchecked") public JSONObject toJSONObject() { JSONObject result = new JSONObject(); result.put("gps", this.gps); return result; }
From source file:com.mobicage.rogerthat.form.UnicodeWidgetResult.java
@SuppressWarnings("unchecked") @Override/* w w w . ja va 2s . c o m*/ public JSONObject toJSONObject() { JSONObject obj = new JSONObject(); obj.put("value", value); return obj; }
From source file:com.mobicage.rogerthat.form.FloatWidgetResult.java
@SuppressWarnings("unchecked") @Override/*from w w w.j a v a2 s. c o m*/ public JSONObject toJSONObject() { JSONObject obj = new JSONObject(); obj.put("value", this.value); return obj; }