List of usage examples for com.google.gwt.json.client JSONParser parseLenient
public static JSONValue parseLenient(String jsonString)
From source file:com.alkacon.acacia.client.NativeComplexWidgetRenderer.java
License:Open Source License
/** * Creates a new configured instance.<p> * /*w w w .ja v a 2 s . com*/ * @param configuration the configuration string */ public NativeComplexWidgetRenderer(String configuration) { m_configuration = configuration; m_jsonConfig = JSONParser.parseLenient(configuration).isObject(); }
From source file:com.brazoft.foundation.gwt.client.json.JSON.java
License:Apache License
public static JSONCollection<String> asStringCollection(String json) { JSONCollection<String> collection = asStringCollection(); collection.setArray(JSONParser.parseLenient(json).isArray()); return collection; }
From source file:com.brazoft.foundation.gwt.client.json.JSON.java
License:Apache License
public static JSONCollection<Boolean> asBooleanCollection(String json) { JSONCollection<Boolean> collection = asBooleanCollection(); collection.setArray(JSONParser.parseLenient(json).isArray()); return collection; }
From source file:com.brazoft.foundation.gwt.client.json.JSON.java
License:Apache License
public static JSONCollection<Number> asNumberCollection(String json) { JSONCollection<Number> collection = asNumberCollection(); collection.setArray(JSONParser.parseLenient(json).isArray()); return collection; }
From source file:com.brazoft.foundation.gwt.client.json.JSON.java
License:Apache License
public static JSONObject asObject(String json) { return new JSONObject(JSONParser.parseLenient(json).isObject()); }
From source file:com.dawg6.web.dhcalc.client.JsonUtil.java
License:Open Source License
public static FormData parseFormData(String text) { FormData data = new FormData(); if ((text != null) && (text.trim().length() > 0)) { try {//from w w w.j a va 2 s. c om JSONValue value = JSONParser.parseLenient(text); if (value != null) { JSONObject obj = value.isObject(); if (obj != null) { data.version = JsonUtil.parseVersion(obj.get("version")); data.main = JsonUtil.parseMap(obj.get("main")); data.calculator = JsonUtil.parseMap(obj.get("calculator")); data.items = JsonUtil.parseMap(obj.get("items")); data.passives = JsonUtil.parseMap(obj.get("passives")); data.gems = JsonUtil.parseMap(obj.get("gems")); data.specialItems = JsonUtil.parseMap(obj.get("equipment")); data.skills = JsonUtil.parseMap(obj.get("skills")); data.elementalDamage = JsonUtil.parseMap(obj.get("elementalDamage")); data.skillDamage = JsonUtil.parseMap(obj.get("skillDamage")); data.hero = null; data.career = null; } } } catch (Exception e) { ApplicationPanel.showErrorDialog("Error Parsing Form Data"); GWT.log("Error Parsing JSON Data", e); } } return data; }
From source file:com.dawg6.web.dhcalc.client.JsonUtil.java
License:Open Source License
public static <T extends Enum<T>> Set<T> parseSet(Class<T> clazz, String text) { if ((text == null) || (text.trim().length() == 0)) return null; Set<T> set = new TreeSet<T>(); JSONValue value = JSONParser.parseLenient(text); JSONArray array = value.isArray();/*from w w w . j a v a 2 s . co m*/ if (array == null) return null; for (int i = 0; i < array.size(); i++) { JSONValue e = array.get(i); if (e != null) { JSONString str = e.isString(); if (str != null) { String name = str.stringValue(); if (name != null) { T elem = Enum.valueOf(clazz, name); if (elem != null) { set.add(elem); } } } } } return set; }
From source file:com.dawg6.web.dhcalc.client.JsonUtil.java
License:Open Source License
public static <T extends Enum<T>> Map<T, Double> parseMap(Class<T> clazz, String text) { if (text == null) { return new TreeMap<T, Double>(); } else {// ww w. j a v a2 s . c om JSONValue v = JSONParser.parseLenient(text); Map<String, String> smap = JsonUtil.parseMap(v); Map<T, Double> map = new TreeMap<T, Double>(); for (Map.Entry<String, String> e : smap.entrySet()) { T type = Enum.valueOf(clazz, e.getKey()); Double d = Double.parseDouble(e.getValue()); map.put(type, d); } return map; } }
From source file:com.dawg6.web.dhcalc.client.JsonUtil.java
License:Open Source License
public static <K extends Enum<K>, V extends Enum<V>> Map<K, V> parseMap(Class<K> keyClass, Class<V> valueClass, String text) {// ww w.jav a 2 s . c o m if (text == null) { return new TreeMap<K, V>(); } else { JSONValue v = JSONParser.parseLenient(text); Map<String, String> smap = JsonUtil.parseMap(v); Map<K, V> map = new TreeMap<K, V>(); for (Map.Entry<String, String> e : smap.entrySet()) { K key = Enum.valueOf(keyClass, e.getKey()); V value = Enum.valueOf(valueClass, e.getValue()); map.put(key, value); } return map; } }
From source file:com.dawg6.web.dhcalc.client.JsonUtil.java
License:Open Source License
public static Map<GemSkill, GemAttributeData> parseGemsMap(String text) { if (text == null) { return new TreeMap<GemSkill, GemAttributeData>(); } else {/*from w ww . j av a2 s . co m*/ JSONValue v = JSONParser.parseLenient(text); Map<String, String> smap = JsonUtil.parseMap(v); return Util.createGems(smap); } }