List of usage examples for org.json.simple JSONObject JSONObject
JSONObject
From source file:halive.shootinoutside.common.core.game.map.ItemLayer.java
public JSONObject serializeToJSON() { return new JSONObject(); }
From source file:co.edu.unal.arqdsoft.presentacion.Contenido.java
/** * */ public Contenido() { this.dato = new JSONObject(); this.html = ""; }
From source file:co.edu.UNal.ArquitecturaDeSoftware.Bienestar.Vista.App.Admin.CUDEventos.java
protected static void iniciarWSC(HttpServletRequest request, HttpServletResponse response) throws IOException { ArrayList<UsuarioEntity> usuarios = CtrlAdmin.iniciarWSC(Integer.parseInt(request.getParameter("1")), //id evento Integer.parseInt(request.getParameter("2")), //tamao tabla Integer.parseInt(request.getParameter("3"))//pagina ); // parameter 1: documentoDocente param2: idTaller response.setContentType("application/json;charset=UTF-8"); PrintWriter out = response.getWriter(); JSONArray list1 = new JSONArray(); for (UsuarioEntity usuario : usuarios) { JSONObject obj = new JSONObject(); obj.put("id", usuario.getIdUsuario()); obj.put("titulo", usuario.getNombres() + " " + usuario.getApellidos()); list1.add(obj);//w w w. ja v a 2s . c o m } out.print(list1); }
From source file:mtis.CreateDisplayJson.java
public String getJson(String city, String duration) throws Exception { String finalReturn = ""; JSONArray list = new JSONArray(); JSONObject finalObj = new JSONObject(); ArrayList<String> month = new ArrayList<String>(); month.add("Jan"); month.add("Feb"); month.add("Mar"); month.add("Apr"); month.add("May"); month.add("Jun"); month.add("Jul"); month.add("Aug"); month.add("Sep"); month.add("Oct"); month.add("Nov"); month.add("Dec"); Date d = new Date(); int dayCount = Integer.parseInt(duration); Long dL = d.getTime();//from w w w. j av a 2 s . co m FileReader fr = new FileReader( "C:\\Users\\Server\\Documents\\twitterData\\" + city + "\\traffic_data_" + city + "_display.txt"); BufferedReader br = new BufferedReader(fr); String line = br.readLine(); StringBuffer text = new StringBuffer(); while (line != null) { text.append(line); line = br.readLine(); } String textData = text.toString(); textData = textData.replaceAll("\\n", " "); String fullTokens[] = textData.split("\\$\\$\\$"); for (int i = fullTokens.length - 1; i >= 1; i--) { StringTokenizer st = new StringTokenizer(fullTokens[i], "||"); String dateString = st.nextToken(); Date date = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy").parse(dateString); Long dateL = date.getTime(); //System.out.println(dateL); String name = st.nextToken(); name = name.replaceAll("'", " "); if (dL - ((dayCount + 1) * 86400 * 1000) <= dateL && dateL <= dL - ((dayCount) * 86400 * 1000)) { //System.out.println("i am in"); JSONObject js = new JSONObject(); js.put("userScreenName", name); System.out.println(name); js.put("userProfilePic", st.nextToken()); js.put("userId", st.nextToken()); js.put("statusId", st.nextToken()); js.put("username", st.nextToken()); js.put("text", st.nextToken()); SimpleDateFormat format = new SimpleDateFormat("hh:mm a "); //System.out.println(format.format(date)); //System.out.println(date.getDate()+"-"+month.get(date.getMonth())+" "+format.format(date)); //System.out.println(dateL); js.put("time", date.getDate() + "-" + month.get(date.getMonth()) + " " + format.format(date)); list.add(js); } line = br.readLine(); } finalObj.put("locations", list); br.close(); finalReturn = finalObj.toString(); System.out.println(finalReturn); return finalReturn; }
From source file:naftoreiclag.villagefive.Inventory.java
public String toJSONString() { JSONObject object = new JSONObject(); for (Map.Entry<Integer, InvItem> entry : items.entrySet()) { object.put(entry.getKey(), entry.getValue()); }/* ww w . ja va 2 s .c o m*/ return object.toJSONString(); }
From source file:org.kitodo.data.elasticsearch.index.type.BatchType.java
@SuppressWarnings("unchecked") @Override//from w w w . j av a 2s . com public HttpEntity createDocument(Batch batch) { JSONObject batchObject = new JSONObject(); batchObject.put("title", batch.getTitle()); String type = batch.getType() != null ? batch.getType().toString() : null; batchObject.put("type", type); batchObject.put("processes", addObjectRelation(batch.getProcesses())); return new NStringEntity(batchObject.toJSONString(), ContentType.APPLICATION_JSON); }
From source file:org.kitodo.data.elasticsearch.index.type.DocketType.java
@SuppressWarnings("unchecked") @Override//from w w w . jav a 2 s . co m public HttpEntity createDocument(Docket docket) { JSONObject docketObject = new JSONObject(); docketObject.put("title", docket.getTitle()); docketObject.put("file", docket.getFile()); return new NStringEntity(docketObject.toJSONString(), ContentType.APPLICATION_JSON); }
From source file:org.kitodo.data.elasticsearch.index.type.FilterType.java
@SuppressWarnings("unchecked") @Override//from w ww.j a v a2s. c om public HttpEntity createDocument(Filter filter) { JSONObject propertyObject = new JSONObject(); propertyObject.put("value", filter.getValue()); Integer user = filter.getUser() != null ? filter.getUser().getId() : null; propertyObject.put("user", user); return new NStringEntity(propertyObject.toJSONString(), ContentType.APPLICATION_JSON); }
From source file:org.kitodo.data.elasticsearch.index.type.UserType.java
@SuppressWarnings("unchecked") @Override/* www .j a v a 2 s.c o m*/ public HttpEntity createDocument(User user) { JSONObject userObject = new JSONObject(); userObject.put("name", user.getName()); userObject.put("surname", user.getSurname()); userObject.put("login", user.getLogin()); userObject.put("ldapLogin", user.getLdapLogin()); userObject.put("active", String.valueOf(user.isActive())); userObject.put("location", user.getLocation()); userObject.put("metadataLanguage", user.getMetadataLanguage()); userObject.put("userGroups", addObjectRelation(user.getUserGroups())); userObject.put("filters", addObjectRelation(user.getFilters())); userObject.put("projects", addObjectRelation(user.getProjects())); userObject.put("processingTasks", addObjectRelation(user.getProcessingTasks())); userObject.put("tasks", addObjectRelation(user.getTasks())); return new NStringEntity(userObject.toJSONString(), ContentType.APPLICATION_JSON); }
From source file:Cache.Cache1.java
public JSONObject fn(JSONObject request) { //String http_method = null; String string_busqueda = (String) request.get("busqueda"); JSONObject respuesta = new JSONObject(); //OPERACIONES CON CACHE //======================================================================================================= // La hebra busca en la particin esttica del cache. // En caso de no encontrar la entrada, busca en la particin LRU correspondiente. // Si queda espacio en el cache esttico, la entrada se agrega al mismo. // Si no se encuentra en el LRU, se pide al IndexService. String estaEnCacheEstatico = cestatico.getEntryFromCache(string_busqueda); // Buscar en el cache esttico if (estaEnCacheEstatico == null) { // Si no esta en el cache estatico int lleno = cestatico.lleno(); //************* MISS EN CACHE ESTATICO DEVUELVOO MISS********************* if (lleno == 0)// y an no esta lleno, agregar al mismo. {//w w w. j a v a2s . co m System.out.println("Miss en cache esttico"); respuesta.put("id", string_busqueda); respuesta.put("estado", "miss"); respuesta.put("respuesta", ""); //*********************************************************** } else //si no esta en el cache estatico y este esta lleno entonces pasamos al dinamico { estaEnCacheEstatico = lru_cache1.getEntryFromCache(string_busqueda);// busco en el cache el id del request //*******************MISS EN EL CACHE DINAMICO RETORNO MISS************************ if (estaEnCacheEstatico == null) { // MISS System.out.println("MISS :("); respuesta.put("id", string_busqueda); respuesta.put("estado", "miss"); respuesta.put("respuesta", ""); //**************************************************************** // **********SI ESTA EN EL CACHE dinamico****************************** } else { respuesta.put("estado", "hit"); respuesta.put("id", string_busqueda); respuesta.put("respuesta", estaEnCacheEstatico); System.out.println("HIT!"); } //**************************************************************** lru_cache1.print(1); System.out.println(""); } } else// si esta en el cache estatico { System.out.println("Hit en el cache estatico"); respuesta.put("estado", "hit"); respuesta.put("id", string_busqueda); respuesta.put("respuesta", estaEnCacheEstatico); cestatico.print(); } return respuesta; }