List of usage examples for org.json.simple JSONObject put
V put(K key, V value);
From source file:app.model.game.ExeChooserModel.java
public Game getFileStructureAsJSON(Game g) throws SQLException { JSONArray jsonarr = listfJSON("C:\\Users\\Public\\Arcade\\Games\\" + g.getGameID() + "\\game"); g.setFilePathJSON(jsonarr);/*from w w w . j a v a 2 s . c om*/ try (SQLHelper sql = new SQLHelper()) { ResultSet rs = sql.execQuery("SELECT executePath FROM games WHERE ID = " + g.getGameID()); if (rs.next()) { JSONObject obj = new JSONObject(); obj.put("file", rs.getString("executePath")); g.setFullFilePath(obj.toJSONString()); } } return g; }
From source file:clientserver.ServerThread.java
final void initClientData() { try {//from w w w . j av a2 s .c o m OutputStreamWriter os = new OutputStreamWriter(socket.getOutputStream(), StandardCharsets.UTF_8); JSONObject jWriteobj = new JSONObject(); jWriteobj.put("name1", "sp_on"); jWriteobj.put("value1", 245); jWriteobj.put("name2", "sp_off"); jWriteobj.put("value2", 45); jWriteobj.put("name3", "mc_on"); jWriteobj.put("value3", 3455); jWriteobj.put("name4", "mc_off"); jWriteobj.put("value4", 2045); os.write(jWriteobj.toString()); os.flush(); } catch (IOException e) { System.out.println("Write socket closing" + e.getMessage()); } }
From source file:com.conwet.silbops.api.impl.XJSPPubEndpoint.java
@SuppressWarnings("unchecked") private void sendAdvertise(Advertise advertise, MessageType type) throws EndPointException { JSONObject payload = new JSONObject(); payload.put("advertise", advertise.toJSON()); payload.put("context", Advertise.asAdvertise(context).toJSON()); writeJSON(type, payload);/*from w ww . ja v a2 s .c o m*/ }
From source file:com.shazam.dataengineering.pipelinebuilder.Deployment.java
public JSONObject toJSON() { JSONArray messageArray = new JSONArray(); for (String message : messages) { messageArray.add(message);/*from w w w .j a v a2 s . c om*/ } JSONObject deployment = new JSONObject(); deployment.put("username", username); deployment.put("status", status); deployment.put("pipelineId", pipelineId); deployment.put("date", date.getTime()); deployment.put("messages", messageArray); return deployment; }
From source file:control.UsuariosServlets.InsertarUsuario.java
/** * Handles the HTTP <code>POST</code> method. * * @param request servlet request/*from ww w. j av a 2 s. 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 { Integer respuesta = 0; try { String usuario = request.getParameter("descripcion"); Integer rol = Integer.parseInt(request.getParameter("rol")); Usuarios manager = new Usuarios(); respuesta = manager.insertarUsuarios(usuario, rol); //Armamos la respuesta JSON y la enviamos response.setContentType("application/json"); JSONObject jsonObject = new JSONObject(); jsonObject.put("error", respuesta); response.getWriter().write(jsonObject.toString()); } catch (Exception ex) { //Armamos la respuesta JSON y la enviamos response.setContentType("application/json"); JSONObject jsonObject = new JSONObject(); jsonObject.put("error", respuesta); response.getWriter().write(jsonObject.toString()); } }
From source file:io.personium.client.BoxManager.java
/** * This method is used to create a Box from Box object. * @param obj Box object/* w w w. j a v a 2 s .c om*/ * @return Box object that is created * @throws DaoException Exception thrown */ @SuppressWarnings("unchecked") public Box create(Box obj) throws DaoException { JSONObject body = new JSONObject(); body.put("Name", obj.getName()); body.put("Schema", obj.getSchema()); JSONObject json = internalCreate(body); String path = UrlUtils.append(accessor.getCurrentCell().getUrl(), (String) body.get("Name")); obj.initialize(this.accessor, json, path); return obj; }
From source file:org.kitodo.data.index.elasticsearch.type.UserType.java
@SuppressWarnings("unchecked") @Override/*from w w w.java2 s.c o m*/ public HttpEntity createDocument(User user) { LinkedHashMap<String, String> orderedUserMap = new LinkedHashMap<>(); orderedUserMap.put("name", user.getName()); orderedUserMap.put("surname", user.getSurname()); orderedUserMap.put("login", user.getLogin()); orderedUserMap.put("ldapLogin", user.getLdapLogin()); orderedUserMap.put("active", String.valueOf(user.isActive())); orderedUserMap.put("location", user.getLocation()); orderedUserMap.put("metadataLanguage", user.getMetadataLanguage()); String ldapGroup = user.getLdapGroup() != null ? user.getLdapGroup().getId().toString() : "null"; orderedUserMap.put("ldapGroup", ldapGroup); JSONObject userObject = new JSONObject(orderedUserMap); JSONArray userGroups = new JSONArray(); List<UserGroup> userUserGroups = user.getUserGroups(); for (UserGroup userGroup : userUserGroups) { JSONObject userGroupObject = new JSONObject(); userGroupObject.put("id", userGroup.getId().toString()); userGroups.add(userGroupObject); } userObject.put("userGroups", userGroups); JSONArray properties = new JSONArray(); List<UserProperty> userProperties = user.getProperties(); for (UserProperty property : userProperties) { JSONObject propertyObject = new JSONObject(); propertyObject.put("title", property.getTitle()); propertyObject.put("value", property.getValue()); properties.add(propertyObject); } userObject.put("properties", properties); return new NStringEntity(userObject.toJSONString(), ContentType.APPLICATION_JSON); }
From source file:anotadorderelacoes.model.Termo.java
/** * Retorna uma representao em formato JSON deste termo * //from w ww . ja va 2s.c om * @return Objeto JSONObject que representa este termo */ public JSONObject toJson() { JSONObject o = new JSONObject(); o.put("de", de); o.put("ate", ate); return o; }
From source file:com.conwet.silbops.api.impl.XJSPPubEndpoint.java
@Override @SuppressWarnings("unchecked") public void publish(Notification not) throws EndPointException { JSONObject payload = new JSONObject(); payload.put("notification", not.toJSON()); payload.put("context", context.toJSON()); writeJSON(MessageType.PUBLISH, payload); }
From source file:com.conwet.xjsp.features.ImmutableMessage.java
@Override @SuppressWarnings("unchecked") public JSONObject toJSONObject(FeatureMap fm) { JSONObject object = new JSONObject(); object.put("id", id); object.put("type", fm.getPrefix(this.getFeature()) + ":" + messageType); object.put("message", payload); return object; }