List of usage examples for com.google.gwt.json.client JSONValue isString
public JSONString isString()
From source file:com.mcherm.zithiacharsheet.client.model.JSONDeserializer.java
License:Apache License
protected void updateFromField(JSONObject parent, String fieldName, SettableStringValue settableStringValue) { JSONValue valueValue = parent.get(fieldName); String actualValue;//from w ww.ja v a2s. com if (valueValue == null) { actualValue = ""; } else { JSONString valueString = notNull(valueValue.isString()); actualValue = valueString.stringValue(); } settableStringValue.setValue(actualValue); }
From source file:com.mcherm.zithiacharsheet.client.model.JSONDeserializer.java
License:Apache License
protected void updateFromFieldRace(JSONObject parent, String fieldName, SettableEnumValue<Race> settableRaceValue) { JSONValue valueValue = notNull(parent.get(fieldName)); JSONString valueString = notNull(valueValue.isString()); String raceName = valueString.stringValue(); settableRaceValue.setValue(Race.valueOf(raceName)); }
From source file:com.mcherm.zithiacharsheet.client.model.JSONDeserializer.java
License:Apache License
protected void updateFromFieldArmorType(JSONObject parent, String fieldName, SettableEnumValue<ArmorType> settableArmorTypeValue) { JSONValue valueValue = notNull(parent.get(fieldName)); JSONString valueString = notNull(valueValue.isString()); String armorTypeName = valueString.stringValue(); settableArmorTypeValue.setValue(ArmorType.valueOf(armorTypeName)); }
From source file:com.mcherm.zithiacharsheet.client.model.JSONDeserializer.java
License:Apache License
protected ZithiaSkill lookupSkill(JSONValue input) { JSONObject inputObj = notNull(input.isObject()); JSONValue idValue = notNull(inputObj.get("id")); JSONString idString = notNull(idValue.isString()); String id = idString.stringValue(); return notNull(SkillCatalog.get(id)); }
From source file:com.mcherm.zithiacharsheet.client.model.JSONDeserializer.java
License:Apache License
protected WeaponSkill lookupWeaponSkill(JSONValue input) { JSONObject inputObj = notNull(input.isObject()); JSONValue idValue = notNull(inputObj.get("id")); JSONString idString = notNull(idValue.isString()); String id = idString.stringValue(); return notNull(WeaponsCatalog.getSingleton().getWeaponSkillById(id)); }
From source file:com.moesol.gwt.maps.client.tms.FeatureReader.java
License:Open Source License
private String getStringProperty(String propertyName, JSONObject obj) { JSONValue jsonValue = obj.get(propertyName); if (jsonValue != null) { JSONString jsonString = jsonValue.isString(); if (jsonString != null) { return jsonString.stringValue(); }//from w ww. ja v a2 s.c o m } return null; }
From source file:com.palmagroup.gwt.orders.client.gin.JsonConverter.java
License:Open Source License
/** * Decodes a JSONObject to a map.// ww w.java 2 s . com * * @param jso * the JSONObject * @return the map */ public static Map<String, Object> decode(JSONObject jso) { Map<String, Object> map = new FastMap<Object>(); for (String key : jso.keySet()) { JSONValue j = jso.get(key); if (j.isObject() != null) { map.put(key, decode(j.isObject())); } else if (j.isArray() != null) { map.put(key, decodeToList(j.isArray())); } else if (j.isBoolean() != null) { map.put(key, j.isBoolean().booleanValue()); } else if (j.isNumber() != null) { map.put(key, j.isNumber().doubleValue()); } else if (j.isString() != null) { map.put(key, decodeValue(j.isString().stringValue())); } } return map; }
From source file:com.parabay.client.utils.JSONCodec.java
License:Apache License
/** * Converts a JSONValue to a Java object. * //from w ww . ja v a 2s. c o m * @param value * @return */ private Object buildJavaObjectFromJSONValue(JSONValue value) { if (value.isNull() != null) { return null; } if (value.isBoolean() != null) { return Boolean.valueOf(value.isBoolean().booleanValue()); } if (value.isString() != null) { return value.isString().stringValue(); } if (value.isNumber() != null) { return buildNumber(value.isNumber().toString()); } if (value.isArray() != null) { return buildJavaArrayFromJSONArray(value.isArray()); } if (value.isObject() != null) { return buildJavaMapFromJSONObject(value.isObject()); } return null; }
From source file:com.ponysdk.core.terminal.PonySDK.java
License:Apache License
/** * From Main terminal to the server/* w w w. j a v a 2 s . co m*/ * Ajax implementation */ public void sendDataToServer(final Object objectID, final JavaScriptObject jsObject, final AjaxCallback callback) { if (callback == null) { final PTInstruction instruction = new PTInstruction(Integer.valueOf(objectID.toString())); instruction.put(ClientToServerModel.NATIVE, jsObject); uiBuilder.sendDataToServer(instruction); } else { final XMLHttpRequest xhr = Browser.getWindow().newXMLHttpRequest(); final PTObject ptObject = uiBuilder.getPTObject(Integer.parseInt(objectID.toString())); xhr.setOnload(evt -> callback.setAjaxResponse(xhr.getResponseText())); xhr.open("GET", MappingPath.AJAX); xhr.setRequestHeader(ClientToServerModel.UI_CONTEXT_ID.name(), String.valueOf(contextId)); xhr.setRequestHeader(ClientToServerModel.OBJECT_ID.name(), String.valueOf(ptObject.getObjectID())); final JSONObject jsonArray = new JSONObject(jsObject); for (final String key : jsonArray.keySet()) { final JSONValue jsonValue = jsonArray.get(key); final JSONString stringValue = jsonValue.isString(); xhr.setRequestHeader(key, stringValue != null ? stringValue.stringValue() : jsonValue.toString()); } xhr.send(); } }
From source file:com.qualogy.qafe.gwt.client.util.JSNIUtil.java
License:Apache License
/** * Convert JavaScript objects to their Java representations. */// w w w.ja v a 2 s .c o m static Object resolveJavaValue(JSONValue jsonValue) { if (jsonValue == null) { return null; } Object value = null; if (jsonValue.isArray() != null) { value = resolveJavaList(jsonValue.isArray()); } else if (jsonValue.isObject() != null) { value = resolveJavaMap(jsonValue.isObject()); } else if (jsonValue.isBoolean() != null) { value = jsonValue.isBoolean().booleanValue(); } else if (jsonValue.isNumber() != null) { value = jsonValue.isNumber().doubleValue(); } else if (jsonValue.isString() != null) { value = jsonValue.isString().stringValue(); } return value; }