List of usage examples for org.json.simple JSONObject JSONObject
JSONObject
From source file:com.conwet.silbops.msg.MockMessage.java
@Override public JSONObject getPayloadAsJSON() { return new JSONObject(); }
From source file:di.uniba.it.tee2.api.v1.GetDocument.java
@GET public Response search(@PathParam("docid") String docid) { try {/* w ww. j a va2s. c om*/ SearchServiceWrapper instance = SearchServiceWrapper.getInstance( ServerConfig.getInstance().getProperty("search.language"), ServerConfig.getInstance().getProperty("search.index")); Document document = instance.getSearch().getDocument(docid); JSONObject json = new JSONObject(); json.put("id", document.get("id")); json.put("title", document.get("title")); json.put("content", document.get("content")); return Response.ok(json.toString()).build(); } catch (Exception ex) { Logger.getLogger(GetDocument.class.getName()).log(Level.SEVERE, null, ex); return Response.serverError().build(); } }
From source file:com.imagelake.android.myuploads.CreateMyUploadthumbnail.java
public String createThumb(int uid) { System.out.println("uid=" + uid); String img = ""; List<Images> imlist = idi.getMyUpload(uid); if (!imlist.isEmpty()) { for (Images images : imlist) { if (images.getUser_user_id() == uid) { if (images.getImage_state_image_state_id() != 7) { JSONObject jo = new JSONObject(); jo.put("img_id", images.getImages_id()); jo.put("title", images.getTitle()); jo.put("state", images.getImage_state_image_state_id()); jo.put("url", images.getImg_url()); ja.add(jo);//from w w w . jav a 2 s . c o m } } } if (!ja.isEmpty()) { img = "json=" + ja.toJSONString(); } else { img = "msg=No item found."; } } else { img = "msg=No item found."; } System.gc(); return img; }
From source file:com.aerothai.database.user.UserService.java
public JSONObject GetUserAll(String role, String opt) throws Exception { ArrayList<UserObj> feeds = new ArrayList<UserObj>(); Connection dbConn = null;/*from w w w. j a v a2 s . c o m*/ JSONObject obj = new JSONObject(); JSONArray objList = new JSONArray(); int no = 1; //obj.put("draw", 2); obj.put("tag", "list"); obj.put("msg", "error"); obj.put("status", false); try { dbConn = DBConnection.createConnection(); Statement stmt = dbConn.createStatement(); String query = "SELECT * ," + "(SELECT dept.name FROM dept where dept.iddept=user.iddept) as shdept," + "(SELECT unit.name FROM unit where unit.idunit=user.idunit) as shunit," + "(SELECT role.name FROM role where role.idrole=user.idrole) as shrole" + " FROM user"; if (!role.equals("0")) { query = query + " WHERE idrole =" + role; if (isNotNull(opt)) query = query + " AND " + opt; } else { if (isNotNull(opt)) query = query + " WHERE " + opt; } System.out.println(query); ResultSet rs = stmt.executeQuery(query); while (rs.next()) { JSONObject jsonData = new JSONObject(); jsonData.put("iduser", rs.getInt("iduser")); jsonData.put("name", rs.getString("name")); jsonData.put("lastname", rs.getString("lastname")); jsonData.put("idposition", rs.getInt("idposition")); jsonData.put("iddept", rs.getInt("iddept")); ; jsonData.put("idunit", rs.getInt("idunit")); jsonData.put("idrole", rs.getInt("idrole")); jsonData.put("address", rs.getString("address")); jsonData.put("email", rs.getString("email")); jsonData.put("tel", rs.getString("tel")); jsonData.put("actunit", rs.getString("actunit")); jsonData.put("username", rs.getString("username")); jsonData.put("photo", rs.getString("photo")); jsonData.put("actcust", rs.getString("actcust")); //jsonData.put("namedept",rs.getString("dept.name")); //jsonData.put("shortdept",rs.getString("shortname")); jsonData.put("shdept", rs.getString("shdept")); jsonData.put("shunit", rs.getString("shunit")); jsonData.put("shrole", rs.getString("shrole")); jsonData.put("no", no); objList.add(jsonData); no++; } obj.put("msg", "done"); obj.put("status", true); obj.put("data", objList); } catch (SQLException sqle) { throw sqle; } catch (Exception e) { // TODO Auto-generated catch block if (dbConn != null) { dbConn.close(); } throw e; } finally { if (dbConn != null) { dbConn.close(); } } return obj; }
From source file:com.dubture.twig.core.model.Test.java
@SuppressWarnings("unchecked") @Override/*from ww w . j av a 2 s .co m*/ public String getMetadata() { JSONObject data = new JSONObject(); data.put(PHPCLASS, phpClass); data.put(DOC, getDocString()); data.put(INTERNAL, internalFunction); return data.toString(); }
From source file:jenkins.plugins.testrail.util.TestRailJsonParser.java
public TestRailJsonParser() { this.newTestPlanJsonString = ""; this.newTestPlanJsonObject = new JSONObject(); }
From source file:io.hawt.testing.env.builtin.NotFound.java
@Override public void handle(HttpServletRequest req, HttpServletResponse resp) throws IOException { resp.setStatus(HttpServletResponse.SC_NOT_FOUND); resp.setContentType("application/json"); resp.setCharacterEncoding("UTF-8"); JSONObject r = new JSONObject(); r.put("error", HttpServletResponse.SC_NOT_FOUND); r.put("message", "Environment not found"); resp.getWriter().println(r.toJSONString()); resp.getWriter().close();//ww w .jav a 2 s. c om }
From source file:io.personium.test.jersey.cell.ctl.CellCtlUtils.java
/** * ???????Relation??./*from ww w . j a va 2 s. c om*/ * @param cellName ?? * @param testRelationName ?? * @param boxname ?? * @return ? */ @SuppressWarnings("unchecked") public static TResponse createRelation(String cellName, String testRelationName, String boxname) { JSONObject body = new JSONObject(); body.put("Name", testRelationName); body.put("_Box.Name", boxname); 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:modelo.AutenticacionManager.PermisosAcceso.java
public JSONArray SeleccionarPermisos(String rol) throws SQLException { JSONArray permisos = new JSONArray(); JSONArray ArrayPantallas = new JSONArray(); JSONObject modulos = new JSONObject(); JSONObject pantallas = new JSONObject(); Boolean flag = true;/*from w w w .j av a2 s . co m*/ String modulo = ""; String codigo_modulo = ""; SeleccionarPermisos select = new SeleccionarPermisos(); ResultSet result = select.getModulos(); while (result.next()) { modulo = result.getString("VAR_MODULO"); codigo_modulo = result.getString("PK_CODIGO"); modulos.put("modulo", modulo); ResultSet rstPantallas = select.getPantallas(rol, codigo_modulo); while (rstPantallas.next()) { pantallas.put("codigo", rstPantallas.getString("PK_CODIGO")); pantallas.put("jsp", rstPantallas.getString("VAR_PANTALLA")); pantallas.put("pantalla", rstPantallas.getString("VAR_DESCRIPCION")); pantallas.put("existe", rstPantallas.getString("EXISTE")); ArrayPantallas.add(pantallas.clone()); pantallas.clear(); } modulos.put("pantallas", ArrayPantallas.clone()); ArrayPantallas.clear(); permisos.add(modulos.clone()); } select.desconectar(); return permisos; }
From source file:com.oic.utils.TestValiadtion.java
public void testStudentId() { JSONObject json = new JSONObject(); Validators v = new Validators(json); v.add("student", v.studentId()); assertFalse(v.validate());/*from w w w . j a v a2 s . c o m*/ json.put("student", "aaaa"); v = new Validators(json); v.add("student", v.studentId()); assertFalse(v.validate()); json.put("student", "z9999"); v = new Validators(json); v.add("student", v.studentId()); assertTrue(v.validate()); }