List of usage examples for org.json.simple JSONObject toString
@Override
public String toString()
From source file:prodandes.ServiciosMock.java
@POST @Path("/registrarPedido") public JSONObject registrarPedido(JSONObject jO) throws Exception { System.out.println("jO " + jO.toJSONString()); System.out.println("jO " + jO.toString()); String nomProducto = jO.get("nombre").toString(); int id_cliente = (int) jO.get("id_cliente"); int cantidad = (int) jO.get("cantidad"); String fecha = jO.get("fechaEsperada").toString(); JSONObject jr = new JSONObject(); jr.put("Respuesta", "Hola"); return jr;/* w ww .j ava 2 s. c o m*/ }
From source file:prodandes.ServiciosMock.java
@POST @Path("/registrarProveedor") public JSONObject registrarProveedor(JSONObject jO) throws Exception { System.out.println("jO " + jO.toJSONString()); System.out.println("jO " + jO.toString()); JSONObject jr = new JSONObject(); jr.put("Respuesta", "Hola"); return jr;//from ww w . j a va 2s . co m }
From source file:prodandes.ServiciosMock.java
@POST @Path("/registrarEjecucionEtapa") public JSONObject registrarEjecucionEtapa(JSONObject jO) throws Exception { System.out.println("jO " + jO.toJSONString()); System.out.println("jO " + jO.toString()); JSONObject jr = new JSONObject(); jr.put("Respuesta", "Hola"); return jr;//from w ww . j av a 2s. c om }
From source file:prodandes.ServiciosMock.java
@POST @Path("/llegadaComponente") public JSONObject llegadaComponente(JSONObject jO) throws Exception { System.out.println("jO " + jO.toJSONString()); System.out.println("jO " + jO.toString()); JSONObject jr = new JSONObject(); jr.put("Respuesta", "Hola"); return jr;/*from w w w . ja v a2 s . co m*/ }
From source file:prodandes.ServiciosMock.java
@POST @Path("/llegadaMaterial") public JSONObject llegadaMaterial(JSONObject jO) throws Exception { System.out.println("jO " + jO.toJSONString()); System.out.println("jO " + jO.toString()); JSONObject jr = new JSONObject(); jr.put("Respuesta", "Hola"); return jr;// w w w .jav a 2s. c o m }
From source file:product.ValidateToken.java
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { JSONObject arrayObj = new JSONObject(); String access_token = request.getParameter("access_token"); String query = "SELECT * FROM tokendata WHERE token='" + access_token + "'"; try {/*from w ww .j a va 2 s . c o m*/ Connection currentCon = ConnectionManager.getConnection(); Statement stmt = currentCon.createStatement(); ResultSet rs = stmt.executeQuery(query); boolean valid = rs.next(); System.out.println("ADA TOKEN TAU GAK = " + valid); if (valid) { Timestamp create_time = getTimeStamp(access_token); Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(create_time.getTime()); cal.add(Calendar.MINUTE, 30); Timestamp expired_time = new Timestamp(cal.getTimeInMillis()); Timestamp current_time = new Timestamp(System.currentTimeMillis()); if (expired_time.before(current_time)) { arrayObj.put("status", "expired"); } else { arrayObj = getJsonObj(access_token); setCreateTime(getUserID(access_token), access_token, current_time); } } else { arrayObj.put("status", "non-valid"); } } catch (SQLException se) { System.out.println(se); } response.setContentType("application/json:charset=UTF-8"); response.getWriter().write(arrayObj.toString()); }
From source file:project.cs.lisa.netinf.node.metadata.MetadataParser.java
/** * Extracts MIME Content-type from a JSON Object metadata. * Metadata has at least the format://from w w w. j av a2 s . c o m * * { "metadata" : { * "ct" : "content-type" * } * } * * Obviously, the metadata field should be there. The JSON Object * may contain other values. * @param json JSON Object * @return String with */ public String extractMimeContentType(JSONObject json) { Log.d(TAG, "" + json.toString()); // Value ct (Content-type) String TAG_metadata_ct = "ct"; // return string String mimetype = null; // Populate JSON Array with metadata // get metadata information mJSONMetadata = (JSONObject) json.get(TAG_metadata); try { // extract mimetype mimetype = mJSONMetadata.getString(TAG_metadata_ct); Log.d(TAG, "mimetype read: " + mimetype); } catch (JSONException e) { // TODO Auto-generated catch block Log.d(TAG, "Malformed metadata!"); Log.d(TAG, "" + e.toString()); e.printStackTrace(); throw new RuntimeException(e); } return mimetype; }
From source file:project.cs.netinfservice.netinf.node.search.UrlSearchService.java
/** * Gets the metadata from the metadata field in the JSON result from NRS. * /*from w w w . java2 s .c o m*/ * @param meta * The metadata field value * @return * String with the metadata from the metadata field */ private String getMetadataFromResults(JSONObject meta) { return meta.toString(); }
From source file:project.cs.netinfservice.util.metadata.Metadata.java
/** * Creates a JSON string with the key "meta" set to the JSON string representation of the * metadata./*from w w w.j a va 2 s . c om*/ * * @return * The JSON Object as a string. */ @SuppressWarnings("unchecked") public String convertToMetadataString() { JSONObject meta = new JSONObject(); meta.put("meta", mJSONObject); return meta.toString(); }
From source file:project.cs.netinfutilities.metadata.Metadata.java
/** * Creates a JSON string with the key "meta" * set to the JSON string representation of the metadata. * /*from ww w . jav a 2 s. c om*/ * @return The JSON string */ @SuppressWarnings("unchecked") public String convertToMetadataString() { JSONObject meta = new JSONObject(); // TODO: check if this still works under json.simple meta.put("meta", mJSONObject); return meta.toString(); }