List of usage examples for org.json.simple JSONObject JSONObject
JSONObject
From source file:br.com.painel.controller.LoginController.java
@RequestMapping("/recuperarSenha") public @ResponseBody String recuperarSenha(Usuario usuario) throws EmailException { UsuarioDAO dao = new UsuarioDAO(); JSONObject json = new JSONObject(); if (dao.verificarEmail(usuario)) { Usuario usu;// w w w . j a v a 2 s . co m EnviarEmail email = new EnviarEmail(); usu = dao.recuperarSenha(usuario); String mensagem = "Usuario: " + usu.getLogin().getUsername() + "\n Senha: " + usu.getLogin().getSenha() + "\n No responder esse email, em caso de dvidas entre em contato com o adminstrador."; email.enviarEmail(usuario.getEmail(), usu.getNome(), "Recuperao de senha", mensagem); json.put("retorno", "Sua senha foi enviada para seu email"); return json.toString(); } json.put("retorno", "Email nao cadastrado!"); return json.toString(); }
From source file:modelo.ProcesoVertimientosManagers.VerificacionInfoCaracterizacion.java
public JSONArray getVerificacionInfoCaracterizacion(Integer codigoProceso, Integer tipoInforme) throws SQLException { ResultSet rset = null;//from w ww . j a v a2 s . co m JSONArray jsonArray = new JSONArray(); JSONObject jsonObject = new JSONObject(); JSONArray jsonArrayPreguntas = new JSONArray(); //Se crea el objeto SeleccionarVerificacionInfoCaracterizacion select = new SeleccionarVerificacionInfoCaracterizacion( codigoProceso, tipoInforme); //Seleccionamos los "Hijos" y "Nietos" del requisito "Padre" rset = select.getVerificaciones(); while (rset.next()) { jsonObject.put("codigo", rset.getString("CODIGO")); jsonObject.put("reguisito", rset.getString("DESCRIPCION")); jsonObject.put("fk_informe", rset.getString("FK_TIPO_INFORME")); jsonObject.put("checkeado", rset.getString("TIENE")); jsonArray.add(jsonObject.clone()); } jsonArrayPreguntas.add(jsonArray.clone()); //Se cierra el ResultSet rset.close(); select.desconectar(); return jsonArrayPreguntas; }
From source file:com.studevs.controllers.Index.java
@RequestMapping(value = "ajax_test") @ResponseBody//from w ww . j a v a 2 s.co m public String doRequest2() { // JSONArray array = new JSONArray(); // // JSONObject object1 = new JSONObject(); // object1.put("number", String.valueOf(new Random().nextInt() * 1000)+" 1"); // object1.put("date", new Date().toString()+" 1"); // // JSONObject object2 = new JSONObject(); // object2.put("number", String.valueOf(new Random().nextInt() * 1000)+" 2"); // object2.put("date", new Date().toString()+" 2"); JSONObject object3 = new JSONObject(); object3.put("number", String.valueOf(new Random().nextInt() * 1000) + " 3"); object3.put("date", new Date().toString() + " 3"); // array.add(object1); // array.add(object2); // array.add(object3); return object3.toJSONString(); }
From source file:com.tom.deleteme.PrintAnnotations.java
public static JSONObject printAnnotations(CAS aCAS, PrintStream aOut) { // get iterator over annotations FSIterator iter = aCAS.getAnnotationIndex().iterator(); Map<String, String> map = new LinkedHashMap<String, String>(); JSONObject json = new JSONObject(); // iterate/*from w w w . j a v a 2s.c o m*/ while (iter.isValid()) { FeatureStructure fs = iter.get(); printAnnotatedText(fs, aCAS, 0, aOut, json); iter.moveToNext(); } return json; }
From source file:org.kitodo.data.index.elasticsearch.type.UserGroupType.java
@SuppressWarnings("unchecked") @Override/*from ww w. java2 s. c o m*/ public HttpEntity createDocument(UserGroup userGroup) { LinkedHashMap<String, String> orderedUserGroupMap = new LinkedHashMap<>(); orderedUserGroupMap.put("title", userGroup.getTitle()); orderedUserGroupMap.put("permission", userGroup.getPermission().toString()); JSONArray users = new JSONArray(); List<User> userGroupUsers = userGroup.getUsers(); for (User user : userGroupUsers) { JSONObject userObject = new JSONObject(); userObject.put("id", user.getId().toString()); users.add(userObject); } JSONObject userGroupObject = new JSONObject(orderedUserGroupMap); userGroupObject.put("users", users); return new NStringEntity(userGroupObject.toJSONString(), ContentType.APPLICATION_JSON); }
From source file:com.cloudera.hoop.fs.FSHomeDir.java
/** * Executes the filesystem operation.// w w w.j ava 2 s . c o m * * @param fs filesystem instance to use. * @return a JSON object with the user home directory. * @throws IOException thrown if an IO error occured. */ @Override @SuppressWarnings("unchecked") public JSONObject execute(FileSystem fs) throws IOException { Path homeDir = fs.getHomeDirectory(); JSONObject json = new JSONObject(); homeDir = FSUtils.convertPathToHoop(homeDir, HoopServer.get().getBaseUrl()); json.put("homeDir", homeDir.toString()); return json; }
From source file:io.personium.client.http.PersoniumBatchRespose.java
/** * This method returns the response body in JSON format. * @return JSONObject//from ww w .j a v a 2s . co m * @throws DaoException Exception thrown */ @SuppressWarnings("unchecked") public final JSONObject bodyAsJson() throws DaoException { JSONObject results = new JSONObject(); results.put("results", new JSONObject()); JSONObject d = new JSONObject(); d.put("d", results); return d; }
From source file:backend.FriendRequestConfirmation.java
@Override public JSONObject jsonize() { JSONObject o = new JSONObject(); o.put("sender", m_receiver.get_user_id()); o.put("sender_alias", m_receiver.get_alias()); o.put("receiver", m_sender.get_user_id()); o.put("receiver_alias", m_sender.get_alias()); return o;//from www. j av a 2s. c o m }
From source file:cn.vlabs.umt.services.user.bean.OauthToken.java
public JSONObject toJson() { JSONObject object = new JSONObject(); object.put("id", id); object.put("accessToken", accessToken); object.put("refreshToken", refreshToken); object.put("createTime", createTime); object.put("accessExpired", accessExpired); object.put("refreshExpired", refreshExpired); object.put("uid", uid); object.put("scope", scope); object.put("clientId", clientId); object.put("redirectURI", redirectURI); return object; }
From source file:net.matthewauld.racetrack.server.WrSQL.java
@SuppressWarnings("unchecked") public String getJSONClassSpecificRiders(String query, String classID) throws SQLException { connect();/*w w w . j av a 2 s . c om*/ st = con.createStatement(); rs = st.executeQuery(query); JSONObject json = new JSONObject(); JSONArray riders = new JSONArray(); while (rs.next()) { JSONObject classJSON = new JSONObject(); classJSON.put("name", fetchRiderName(rs.getInt("id"))); classJSON.put("id", rs.getInt("id")); riders.add(classJSON); } JSONObject classInfo = new JSONObject(); classInfo.put("title", fetchClassTitle(Integer.parseInt(classID))); classInfo.put("cid", Integer.parseInt(classID)); json.put("class", classInfo); if (riders.size() == 0) { json.put("riders", null); } else { json.put("riders", riders); } return json.toJSONString(); }