List of usage examples for org.json.simple JSONObject JSONObject
JSONObject
From source file:fr.nantes.web.quizz.servlets.Nbdirectors.java
@Override public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { int countdirectors = Requetesdatastore.getcountdirectors(); JSONArray result = new JSONArray(); JSONObject map = new JSONObject(); map.put("count", countdirectors); result.add(map);/*from www . ja v a2 s. c o m*/ response.setContentType("application/json;charset=UTF-8"); try (PrintWriter out = response.getWriter()) { out.println(result); } }
From source file:com.megacasting_ppe.web.ServletPageError.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.//from ww w .ja v a 2 s. c o m * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("application/json"); response.setHeader("Cache-Control", "no-cache"); HttpSession session = request.getSession(); JSONObject global = new JSONObject(); if (session.getAttribute("Connecter") != null) { String connecterCandidatOk = (String) session.getAttribute("Connecter"); if (connecterCandidatOk == "false") { global.put("candidatAutherreur", "le nom d'utilisateur ou le mot de passe du candidat est incorrect"); session.removeAttribute("Connecter"); } } if (session.getAttribute("ConnecterDiffuseur") != null) { String connecterDiffuseurOk = (String) session.getAttribute("ConnecterDiffuseur"); if (connecterDiffuseurOk == "false") { global.put("diffuseurAutherreur", "le nom d'utilisateur ou le mot de passe du diffuseur est incorrect"); session.removeAttribute("ConnecterDiffuseur"); } } if (session.getAttribute("ErreurInscriptionCandidat") != null) { String ErreurInscription = (String) session.getAttribute("ErreurInscriptionCandidat"); if (ErreurInscription == "true") { global.put("Inscriptionerreur", "Un ou plusieurs champs saisies dans le formulaire d'inscription sont invalide"); session.removeAttribute("ErreurInscriptionCandidat"); } } try (PrintWriter out = response.getWriter()) { out.println(global.toString()); } }
From source file:com.opensoc.enrichment.adapters.host.HostFromPropertiesFileAdapter.java
@SuppressWarnings("unchecked") @Override/*w ww .j a v a 2 s . c o m*/ public JSONObject enrich(String metadata) { if (!_known_hosts.containsKey(metadata)) return new JSONObject(); JSONObject enrichment = new JSONObject(); enrichment.put("known_info", (JSONObject) _known_hosts.get(metadata)); return enrichment; }
From source file:mysynopsis.SystemInitializer.java
private static void setDefault() throws IOException { JSONObject bio = new JSONObject(); bio.put("Name", ""); bio.put("Initial", ""); bio.put("Bio", "<p><font face=\"Arial\" size=\"4\"><b>Biography goes here</b></font></p><p><br></p><p></p><p><font face=\"Segoe UI\" size=\"4\"><br></font></p>"); bio.put("Designation", ""); bio.put("Department", ""); bio.put("University", ""); bio.put("University_Address", ""); bio.put("Office", ""); bio.put("Ohours", ""); bio.put("Phone", ""); bio.put("Email", ""); bio.put("Resume_Link", ""); bio.put("Educational", "<p><font face=\"Arial\" size=\"4\"><b>Educational Information</b></font></p><p><br></p><p></p><p><font face=\"Segoe UI\" size=\"4\"><br></font></p>"); bio.put("Professional", "<p><font face=\"Arial\" size=\"4\"><b>Professional Experience</b></font></p><p><br></p><p></p><p><font face=\"Segoe UI\" size=\"4\"><br></font></p>"); bio.put("Awards", "<p><font face=\"Arial\" size=\"4\"><b>Awards</b></font></p><p><br></p><p></p><p><font face=\"Segoe UI\" size=\"4\"><br></font></p>"); bio.put("Image_Ext", "png"); bio.put("Image_String", "iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAYAAAA5ZDbSAAAKxklEQVR42u1de2wcRx0eQEAqQQVCAhFaSiv+QfwBqQoECAgJCbUChCoKCJXm2QYngdA0Aadp1IY4zbNJaePWcR7Ow44fiRO/HdmxYyf3ct2QPpI4e3uk0JBU/EMLTbx7O7vsMt+2xCFOfA/v7s3szk/65Lvz3t3sfDczv9f8hoRBXhqxP5XKmN9LpK35CdVcm1RpA3s8kExbp9njt+IK/XdSoTr7+x8Aj/Ga+z/Veh3Xssf1eG88bT2Cz8JnEinBS7dqfzSept9JqNbyhGK1M2IuJVXL8QNxlV5k5Lex7ypPKXQGvptI8V7i5+yprJMXJhWrg4280VzE+Ej4FfyoUqq14PiI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FyuatY5NXfqc3QPOFCIleNnUo9+5sUNfUNGa3b2qWY+taBw9j6n9t0yTxQ8ADoa51e606gKP8Rr+h2twLd6D965ho3NTOy1bd0T/AgmB/Bd/W0C3K+5ULAAAAABJRU5ErkJggg=="); // JSONArray education = new JSONArray(); /*for(int i=0;i<8;i++) { /*from w w w. j ava 2s. c o m*/ education.add(""); } bio.put("Education", education);*/ JSONArray ftpinfo = new JSONArray(); ftpinfo.add(""); ftpinfo.add(""); ftpinfo.add(""); bio.put("Server_Information", ftpinfo); /* JSONArray professional = new JSONArray(); professional.add("Profession 1: "); professional.add("Profession 2: "); bio.put("Professional Experience:", professional); JSONArray awards = new JSONArray(); awards.add("Award 1: "); awards.add("Award 2: "); bio.put("Honors & Awards:", awards);*/ try (FileWriter file = new FileWriter("data.json")) { file.write(bio.toJSONString()); } catch (IOException e) { JOptionPane.showMessageDialog(null, "Can't Create Data.json File. Please Check Your Directory Permission"); } }
From source file:modelo.ParametrizacionManagers.TiposContactos.java
/** * * Llama al delegate para Eliminar una tipo de contacto * @param codigo /*from w w w .j a v a2 s .c o m*/ * @throws Exception */ public JSONArray eliminar(int codigo) throws Exception { JSONArray jsonArray = new JSONArray(); JSONObject jsonObject = new JSONObject(); Integer respError; EliminarTiposContactos delete = new EliminarTiposContactos(codigo); delete.ejecutar(); respError = delete.getError(); jsonObject.put("error", respError); jsonArray.add(jsonObject); return jsonArray; }
From source file:com.piusvelte.hydra.AuthServlet.java
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ServletContext servletContext = getServletContext(); ConnectionManager connMgr = ConnectionManager.getInstance(servletContext); JSONObject j = new JSONObject(); String token = request.getParameter("token"); if ((token != null) && (token.length() > 0)) { try {//w ww. j av a2 s . c o m connMgr.authorizeToken(token); } catch (Exception e) { servletContext.log(e.getMessage()); JSONArray errors = new JSONArray(); errors.add(e.getMessage()); j.put("errors", errors); response.setStatus(403); } } else { try { j.put("result", connMgr.createToken()); } catch (Exception e) { servletContext.log(e.getMessage()); JSONArray errors = new JSONArray(); errors.add(e.getMessage()); j.put("errors", errors); response.setStatus(403); } } response.getWriter().write(j.toJSONString()); }
From source file:fr.nantes.web.quizz.servlets.Adddirectors.java
@Override public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { int nbdirectors = Integer.parseInt(request.getParameter("nbdirectors")); JSONArray result = new JSONArray(); JSONObject map = new JSONObject(); if (nbdirectors > Requetesdatastore.getcountdirectors()) { if (Requetesdatastore.adddirectors(nbdirectors)) { map.put("count", nbdirectors); result.add(map);//from w w w . jav a2 s. c o m } else { map.put("count", 0); result.add(map); } } else { map.put("count", -100); result.add(map); } response.setContentType("application/json;charset=UTF-8"); try (PrintWriter out = response.getWriter()) { out.println(result); } }
From source file:com.consol.citrus.samples.bakery.service.ReportService.java
/** * Gets the status of a very specific item found by its id. * @return/*from w w w. j a v a 2 s. c om*/ */ public String status(String id) { JSONObject statusJSon = new JSONObject(); statusJSon.put("status", produced.contains(id)); return statusJSon.toString(); }
From source file:modelo.ParametrizacionManagers.MotivosVisitas.java
/** * * Llama al delegate para Eliminar un Laboratorio * * @param codigo //from w w w .j a v a2s. co m * @throws Exception */ public JSONArray Eliminar(int codigo) throws Exception { JSONArray jsonArray = new JSONArray(); JSONObject jsonObject = new JSONObject(); Integer respError; EliminarMotivosVisitas delete = new EliminarMotivosVisitas(codigo); delete.ejecutar(); respError = delete.getError(); jsonObject.put("error", respError); jsonArray.add(jsonObject); return jsonArray; }
From source file:com.megacasting_ppe.web.ServletOffreForDiffuseur.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods./*from w ww.ja v a2 s.co m*/ * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("application/json; charset=ISO-8859-1"); response.setHeader("Cache-Control", "no-cache"); JSONObject global = new JSONObject(); JSONArray arrayoffre = new JSONArray(); //on rcupre l'ensemble des offres de casting en BDD for (Offre offre : offreDAO.Lister()) { JSONObject object = new JSONObject(); //Par dfaut il n'y a pas de fin de contrat, dans le cas si l'offre propos est un CDI String datefincontrat = "Aucune Date"; if (offre.getDateFinContrat() != null) { datefincontrat = offre.getDateFinContrat().toString(); } //on retourne les informations de l'offre object.put("Intitule", offre.getLibelle()); object.put("Reference", offre.getReference()); object.put("DateDebutPublication", offre.getDateDebutPublication().toString()); object.put("DateFinPublication", offre.getDateFinPublication().toString()); object.put("DateDebutContrat", offre.getDateDebutContrat().toString()); object.put("DateFinContrat", datefincontrat); object.put("DescriptionPoste", offre.getDescriptionPoste()); object.put("DescriptionProfil", offre.getDescriptionProfil()); object.put("NombresPoste", offre.getNbPoste()); object.put("NomEntreprise", offre.getClient().getNomEntreprise()); object.put("NomResponsable", offre.getClient().getNomResponsable()); object.put("PrenomResponsable", offre.getClient().getPrenomResponsable()); object.put("CiviliteResponsable", offre.getClient().getCiviliteResponsable()); object.put("RueEntreprise", offre.getClient().getRueEntreprise()); object.put("CpEntreprise", offre.getClient().getCpEntreprise()); object.put("VilleEntreprise", offre.getClient().getVilleEntreprise()); object.put("MailEntreprise", offre.getClient().getMailEntreprise()); object.put("FaxEntreprise", offre.getClient().getFaxEntreprise()); object.put("TelephoneEntreprise", offre.getClient().getTelephoneEntreprise()); object.put("Metier", offre.getMetier().getLibelle()); object.put("Contrat", offre.getContrat().getLibelle()); arrayoffre.add(object); } global.put("offres", arrayoffre); try (PrintWriter out = response.getWriter()) { out.println(global.toString()); } }