List of usage examples for org.json.simple JSONObject JSONObject
JSONObject
From source file:cs.rsa.ts14dist.common.CommandLanguage.java
@SuppressWarnings("unchecked") /** Create an invalid reply object */ public static JSONObject createInvalidReplyWithExplantion(String errorMsg) { JSONObject reply = new JSONObject(); reply.put("error", true); reply.put("errorMsg", errorMsg); return reply; }
From source file:org.kitodo.data.elasticsearch.index.type.ProjectType.java
@SuppressWarnings("unchecked") @Override/* ww w . j av a2 s . c o m*/ public HttpEntity createDocument(Project project) { JSONObject projectObject = new JSONObject(); projectObject.put("title", project.getTitle()); String startDate = project.getStartDate() != null ? formatDate(project.getStartDate()) : null; projectObject.put("startDate", startDate); String endDate = project.getEndDate() != null ? formatDate(project.getEndDate()) : null; projectObject.put("endDate", endDate); projectObject.put("numberOfPages", project.getNumberOfPages()); projectObject.put("numberOfVolumes", project.getNumberOfVolumes()); projectObject.put("fileFormatDmsExport", project.getFileFormatDmsExport()); projectObject.put("fileFormatInternal", project.getFileFormatInternal()); String archived = project.getProjectIsArchived() != null ? project.getProjectIsArchived().toString() : null; projectObject.put("archived", archived); projectObject.put("processes", addObjectRelation(project.getProcesses())); projectObject.put("users", addObjectRelation(project.getUsers())); JSONArray projectFileGroups = new JSONArray(); List<ProjectFileGroup> projectProjectFileGroups = project.getProjectFileGroups(); for (ProjectFileGroup projectFileGroup : projectProjectFileGroups) { JSONObject projectFileGroupObject = new JSONObject(); projectFileGroupObject.put("name", projectFileGroup.getName()); projectFileGroupObject.put("path", projectFileGroup.getPath()); projectFileGroupObject.put("mimeType", projectFileGroup.getMimeType()); projectFileGroupObject.put("suffix", projectFileGroup.getSuffix()); projectFileGroupObject.put("folder", projectFileGroup.getFolder()); projectFileGroups.add(projectFileGroupObject); } projectObject.put("projectFileGroups", projectFileGroups); return new NStringEntity(projectObject.toJSONString(), ContentType.APPLICATION_JSON); }
From source file:naftoreiclag.villagefive.InvItem.java
@Override public String toJSONString() { JSONObject object = new JSONObject(); object.put("classId", "itemEntity"); object.put("entityData", entity); return null;/*w w w . j a va 2 s .co m*/ }
From source file:com.dubture.symfony.core.util.JsonUtils.java
@SuppressWarnings("unchecked") public static String createDefaultSyntheticServices() { JSONArray data = new JSONArray(); JSONObject request = new JSONObject(); request.put(Service.NAME, "request"); request.put(Service.CLASS, "Symfony\\Component\\HttpFoundation\\Request"); data.add(request);// ww w. j a v a2 s. co m return data.toString(); }
From source file:com.android.get.AndroidJSONMethod.java
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); try {/*from w ww . j ava 2s. c om*/ String fn = request.getParameter("un"); String pw = request.getParameter("pw"); JSONObject jo = new JSONObject(); if (fn.equals("abc") && pw.equals("123")) { jo.put("fname", "Lakmal"); jo.put("lname", "navarathne"); } out.write(jo.toJSONString()); } finally { out.close(); } }
From source file:ab.server.proxy.message.ProxyScreenshotMessage.java
@Override public JSONObject getJSON() { return new JSONObject(); }
From source file:com.aerothai.database.job.JobService.java
public JSONObject GetJobAll(int idunit, String opt) throws Exception { 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 * FROM job"; if (idunit > 0) { query = query + " WHERE idunit =" + idunit; if (isNotNull(opt)) query = query + " AND " + opt; } else { if (isNotNull(opt)) query = "SELECT * FROM job WHERE" + opt; } System.out.println(query); ResultSet rs = stmt.executeQuery(query); while (rs.next()) { JSONObject jsonData = new JSONObject(); jsonData.put("id", rs.getInt("idjob")); jsonData.put("iduser", rs.getString("iduser")); jsonData.put("idunit", rs.getString("idunit")); jsonData.put("iddevice", rs.getString("iddevice")); jsonData.put("service_method", rs.getString("service_method")); jsonData.put("service_type", rs.getString("service_type")); jsonData.put("details", rs.getString("details")); jsonData.put("action", rs.getString("action")); jsonData.put("remark", rs.getString("remark")); jsonData.put("idstatus", rs.getString("idstatus")); jsonData.put("receive_staff", rs.getString("receive_staff")); jsonData.put("action_staff", rs.getString("action_staff")); jsonData.put("close_staff", rs.getString("close_staff")); jsonData.put("wait_date", rs.getString("wait_date")); jsonData.put("receive_date", rs.getString("receive_date")); jsonData.put("action_date", rs.getString("action_date")); jsonData.put("finish_date", rs.getString("finish_date")); jsonData.put("eva_date", rs.getString("eva_date")); jsonData.put("close_date", rs.getString("close_date")); ; 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.oic.connection.Connections.java
/** * ??? ??/*from w w w. j a v a2 s.c o m*/ */ public static synchronized void checkLive() { new Thread(new Runnable() { @Override public void run() { while (true) { JSONObject json = new JSONObject(); json.put("method", "live"); json.put("status", 0); broadCastMessage(json); try { Thread.sleep(20000); } catch (InterruptedException ex) { } } } }).start(); }
From source file:mn.EngineForge.module.player.java
public void saveRegisteration() throws IOException { JSONObject reg = new JSONObject(); reg.put("ID", id); reg.put("USERNAME", username); reg.put("PASSWORD", password); reg.put("REG_DATE", null); reg.put("LAST_LOGIN", null); reg.put("POSITION", null); /* JSON ARRAY NOTE//from w w w . ja v a 2 s . c o m JSONArray company = new JSONArray(); company.add("Compnay: eBay"); company.add("Compnay: Paypal"); company.add("Compnay: Google"); reg.put("Company List", company); */ FileWriter file = new FileWriter(this.path); try { file.write(reg.toJSONString()); } catch (IOException e) { e.printStackTrace(); } finally { file.flush(); file.close(); } }
From source file:com.aerothai.database.device.DeviceService.java
public JSONObject GetDeviceAll(int idunit, String opt) throws Exception { Connection dbConn = null;// ww w.j a v a 2 s .co 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 * FROM device"; if (idunit > 0) { query = query + " WHERE idunit =" + idunit; if (isNotNull(opt)) query = query + " AND " + opt; } else { if (isNotNull(opt)) query = "SELECT * FROM device WHERE" + opt; } System.out.println(query); ResultSet rs = stmt.executeQuery(query); while (rs.next()) { JSONObject jsonData = new JSONObject(); jsonData.put("id", rs.getInt("iddevice")); jsonData.put("idunit", rs.getString("idunit")); jsonData.put("iddevice_type", rs.getString("iddevice_type")); jsonData.put("idmodel", rs.getString("idmodel")); jsonData.put("idaccessory", rs.getString("idaccessory")); jsonData.put("asset_no", rs.getString("asset_no")); jsonData.put("serial_no", rs.getString("serial_no")); jsonData.put("ip_address", rs.getString("ip_address")); jsonData.put("mac_address", rs.getString("mac_address")); jsonData.put("computer_name", rs.getString("computer_name")); jsonData.put("os", rs.getString("os")); jsonData.put("firmware", rs.getString("firmware")); jsonData.put("vendor", rs.getString("vendor")); jsonData.put("customer", rs.getString("customer")); jsonData.put("address", rs.getString("address")); jsonData.put("location", rs.getString("location")); jsonData.put("insert_date", rs.getString("insert_date")); jsonData.put("receive_date", rs.getString("receive_date")); jsonData.put("exp_date", rs.getString("exp_date")); jsonData.put("image", rs.getString("image")); jsonData.put("id_door", rs.getString("id_door")); jsonData.put("in_out_side", rs.getString("in_out_side")); 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; }