List of usage examples for com.google.gwt.json.client JSONParser parseStrict
public static JSONValue parseStrict(String jsonString)
From source file:annis.gui.widgets.gwt.client.ui.VJITWrapper.java
License:Apache License
public JSONObject parseStringToJSON(String jsonString) { JSONObject json = null;/* w ww . j a va 2s .c o m*/ try { json = JSONParser.parseStrict(jsonString).isObject(); } catch (Exception ex) { GWT.log("this json " + jsonString + " is not parsed", ex); } return json; }
From source file:bufferings.ktr.wjr.client.service.KtrWjrJsonServiceAsync.java
License:Apache License
/** * Creates a WjrConfig from Json string. * // w ww .j a v a2s . c om * @param jsonString * the Json string. * @return the created WjrConfig instance. */ WjrConfig createWjrConfigFromJson(String jsonString) { WjrConfigMeta m = WjrConfigMeta.meta(); WjrConfig wjrConfig = new WjrConfig(); JSONObject j = JSONParser.parseStrict(jsonString).isObject(); wjrConfig.setConfigId(j.get(m.configId).isString().stringValue()); wjrConfig.setConfigName(j.get(m.configName).isString().stringValue()); wjrConfig.setCpumsEnabled(j.get(m.cpumsEnabled).isString().stringValue()); wjrConfig.setApimsEnabled(j.get(m.apimsEnabled).isString().stringValue()); wjrConfig.setLogHookEnabled(j.get(m.logHookEnabled).isString().stringValue()); wjrConfig.setLogHookTimezone(j.get(m.logHookTimezone).isString().stringValue()); wjrConfig.setRetryOverQuotaEnabled(j.get(m.retryOverQuotaEnabled).isString().stringValue()); wjrConfig.setRetryOverQuotaInterval(j.get(m.retryOverQuotaInterval).isString().stringValue()); wjrConfig.setRetryOverQuotaMaxCount(j.get(m.retryOverQuotaMaxCount).isString().stringValue()); return wjrConfig; }
From source file:bufferings.ktr.wjr.client.service.KtrWjrJsonServiceAsync.java
License:Apache License
/** * Creates a WjrStore from Json string.//from www .j av a 2 s. c o m * * @param jsonString * the Json string. * @return the created WjrStore instance. */ WjrStore createWjrStoreFromJson(String jsonString) { WjrStoreMeta m = WjrStoreMeta.meta(); WjrStore wjrStore = new WjrStore(); JSONObject j = JSONParser.parseStrict(jsonString).isObject(); JSONArray classItems = j.get(m.classItems).isArray(); int classItemsSize = classItems.size(); for (int i = 0; i < classItemsSize; i++) { wjrStore.addClassItem(createWjrClassItemFromJson(classItems.get(i).toString())); } JSONArray methodItems = j.get(m.methodItems).isArray(); int methodItemsSize = methodItems.size(); for (int i = 0; i < methodItemsSize; i++) { wjrStore.addMethodItem(createWjrMethodItemFromJson(methodItems.get(i).toString())); } return wjrStore; }
From source file:bufferings.ktr.wjr.client.service.KtrWjrJsonServiceAsync.java
License:Apache License
/** * Creates a WjrClassItem from Json string. * /*from w w w.j a va2 s. co m*/ * @param jsonString * the Json string. * @return the created WjrClassItem instance. */ WjrClassItem createWjrClassItemFromJson(String jsonString) { WjrClassItemMeta m = WjrClassItemMeta.meta(); JSONValue j = JSONParser.parseStrict(jsonString); return new WjrClassItem(j.isObject().get(m.className).isString().stringValue()); }
From source file:bufferings.ktr.wjr.client.service.KtrWjrJsonServiceAsync.java
License:Apache License
/** * Creates a WjrMethodItem from Json string. * /*from w w w . j a v a 2 s . c om*/ * @param jsonString * the Json string. * @return the created WjrMethodItem instance. */ WjrMethodItem createWjrMethodItemFromJson(String jsonString) { WjrMethodItemMeta m = WjrMethodItemMeta.meta(); JSONObject j = JSONParser.parseStrict(jsonString).isObject(); String className = j.get(m.className).isString().stringValue(); String methodName = j.get(m.methodName).isString().stringValue(); WjrMethodItem wjrMethodItem = new WjrMethodItem(className, methodName); wjrMethodItem.setTrace(j.get(m.trace).isString().stringValue()); wjrMethodItem.setLog(j.get(m.log).isString().stringValue()); wjrMethodItem.setTime(j.get(m.time).isString().stringValue()); wjrMethodItem.setCpuTime(j.get(m.cpuTime).isString().stringValue()); wjrMethodItem.setApiTime(j.get(m.apiTime).isString().stringValue()); wjrMethodItem.setOverQuota(j.get(m.isOverQuota).isBoolean().booleanValue()); wjrMethodItem.setRetryCount(new Integer(j.get(m.retryCount).isNumber().toString())); wjrMethodItem.setMaxRetryCount(new Integer(j.get(m.maxRetryCount).isNumber().toString())); wjrMethodItem.setWaitingSeconds(new Integer(j.get(m.waitingSeconds).isNumber().toString())); wjrMethodItem.setState(State.valueOf(j.get(m.state).isString().stringValue())); return wjrMethodItem; }
From source file:ch.gbrain.gwtstorage.model.StorageItem.java
License:Apache License
/** * Converts back from a json string to the object itself * /*from w w w . jav a 2s . c o m*/ * @param jsonString */ @JsonIgnore public void fromJson(String jsonString) { JSONValue val = JSONParser.parseStrict(jsonString); fromJson(val); }
From source file:ch.takoyaki.email.html.client.service.FileServiceImpl.java
License:Open Source License
private List<String> fileList() { List<String> list = new ArrayList<String>(); try {// w w w .ja v a 2 s . c o m if (s().getItem(FILE_LIST) != null) { JSONArray a = (JSONArray) JSONParser.parseStrict(s().getItem(FILE_LIST)); for (int i = 0; i < a.size(); i++) { list.add(((JSONString) a.get(i)).stringValue()); } } } catch (JSONException e) { Log.log("file list corrupted"); } return list; }
From source file:ch.unifr.pai.twice.comm.serverPush.client.RemoteEvent.java
License:Apache License
/** * Decrypts and deserializes the event data * //ww w . j a v a 2 s . c o m * @param string * @param securityManager * @return * @throws MessagingException */ public RemoteEvent<H> deserialize(String string, TWICESecurityManager securityManager) throws MessagingException { root = (JSONObject) JSONParser.parseStrict(string); JSONString data = (JSONString) root.get("data"); json = (JSONObject) JSONParser.parseStrict(securityManager.decryptMessage(data.stringValue())); return this; }
From source file:cimav.client.data.rest.CalculoREST.java
public void calcular(String ids) { BaseREST.setDateFormatPOST();/*from w w w .ja v a 2 s . c om*/ String url = BaseREST.URL_REST_BASE + "api/calculo"; JSONValue jsonValue = JSONParser.parseStrict(ids); Resource rb = new Resource(url, headers); rb.post().json(jsonValue).send(Ajax.jsonCall(new JsonCallback() { @Override public void onFailure(Method method, Throwable exception) { MethodEvent dbEvent = new MethodEvent(EMethod.CALCULAR_ALL, ETypeResult.FAILURE, "CalculoREST.calcular " + exception.getMessage()); onRESTExecuted(dbEvent); } @Override public void onSuccess(Method method, JSONValue response) { try { MethodEvent dbEvent = new MethodEvent(EMethod.CALCULAR_ALL, ETypeResult.SUCCESS, "CalculoREST.calcular listo"); dbEvent.setResult(response); onRESTExecuted(dbEvent); } catch (Exception e) { String error = "CalculoREST.calcular " + e.getMessage(); MethodEvent dbEvent = new MethodEvent(EMethod.CALCULAR_ALL, ETypeResult.FAILURE, error); onRESTExecuted(dbEvent); } } })); }
From source file:cimav.client.data.rest.NominaQuincenalREST.java
public void findByEmpleadoIds(String empleadoIds) { BaseREST.setDateFormatPOST();// w w w. j ava 2 s . co m String url = BaseREST.URL_REST_BASE + "api/movimientos/find_by_empleado_ids"; JSONValue jsonValue = JSONParser.parseStrict(empleadoIds); Resource rb = new Resource(url, headers); rb.post().json(jsonValue).send(Ajax.jsonCall(new JsonCallback() { @Override public void onFailure(Method method, Throwable exception) { MethodEvent dbEvent = new MethodEvent(EMethod.FIND_BY_EMPLEADO_IDS, ETypeResult.FAILURE, "NominaQuincenalREST.FIND_BY_EMPLEADO_IDS " + exception.getMessage()); onRESTExecuted(dbEvent); } @Override public void onSuccess(Method method, JSONValue response) { try { List<Movimiento> result = new ArrayList<>(); JSONArray array = response.isArray(); for (int i = 0; i < array.size(); i++) { JSONValue val = array.get(i); Movimiento nq = jsonCodec.decode(val); result.add(nq); } MethodEvent dbEvent = new MethodEvent(EMethod.FIND_BY_EMPLEADO_IDS, ETypeResult.SUCCESS, "NominaQuincenalREST.FIND_BY_EMPLEADO_IDS listo"); dbEvent.setResult(result); onRESTExecuted(dbEvent); } catch (Exception e) { String error = "NominaQuincenalREST.FIND_BY_EMPLEADO_IDS " + e.getMessage(); MethodEvent dbEvent = new MethodEvent(EMethod.FIND_BY_EMPLEADO_IDS, ETypeResult.FAILURE, error); onRESTExecuted(dbEvent); } } })); }