public static Boolean getBoolean(JSONObject json, String field) { JSONValue jsonValue; JSONBoolean jsonBoolean; if ((jsonValue = json.get(field)) == null) { return null; } if ((jsonBoolean = jsonValue.isBoolean()) == null) { return null; } return jsonBoolean.booleanValue(); }
private static boolean getFieldAsBoolean(JSONValue field) { return field.isBoolean() != null ? field.isBoolean().booleanValue() : false; }
@Override public Boolean decode(JSONValue value) throws DecodingException { if (value == null || value.isNull() != null) { return null; } JSONBoolean bool = value.isBoolean(); if (bool == null) { throw new DecodingException("Expected a json boolean, but was given: " + value); } return bool.booleanValue(); }
public static FileStructureCommandParametersDto fromJson(JSONValue jsonVal) { if (jsonVal == null) { return null; } JSONObject json= jsonVal.isObject(); FileStructureCommandParametersDto result= new FileStructureCommandParametersDto(); JSONValue jsonshowInheritedJson = json.get("showInherited"); if (jsonshowInheritedJson != null && !(jsonshowInheritedJson.isNull() != null)) { boolean jsonshowInheritedVal = jsonshowInheritedJson.isBoolean().booleanValue(); result.setShowInherited((boolean)jsonshowInheritedVal); } JSONValue jsonuriJson = json.get("uri"); if (jsonuriJson != null && !(jsonuriJson.isNull() != null)) { java.lang.String jsonuriVal = jsonuriJson.isString().stringValue();; result.setUri((java.lang.String)jsonuriVal); } return result; } }
@Override public Object decode(JSONValue value) throws JsonEncoderDecoder.DecodingException { if (value instanceof JSONNumber) { return ((JSONNumber) value).doubleValue(); } else if (value instanceof JSONBoolean) { return ((JSONBoolean) value).booleanValue(); } else if (value instanceof JSONString) { return ((JSONString) value).stringValue(); } else if (value instanceof JSONArray) { JSONArray array = value.isArray(); List<Object> list = new ArrayList<Object>(array.size()); for (int ct = 0; ct < array.size(); ct++) { list.add(decode(array.get(ct))); } return list; } else if (value instanceof JSONObject) { JSONObject object = value.isObject(); Map<String, Object> map = new HashMap<String, Object>(); for (String key : object.keySet()) { map.put(key, decode(object.get(key))); } return map; } else { return null; } }
public static ResourceDto fromJson(JSONValue jsonVal) { if (jsonVal == null) { return null; } JSONObject json= jsonVal.isObject(); ResourceDto result= new ResourceDto(); JSONValue jsonpackJson = json.get("pack"); if (jsonpackJson != null && !(jsonpackJson.isNull() != null)) { boolean jsonpackVal = jsonpackJson.isBoolean().booleanValue(); result.setPack((boolean)jsonpackVal); } JSONValue jsonuriJson = json.get("uri"); if (jsonuriJson != null && !(jsonuriJson.isNull() != null)) { java.lang.String jsonuriVal = jsonuriJson.isString().stringValue();; result.setUri((java.lang.String)jsonuriVal); } return result; } }
public static Boolean getParameterboolean( JSONObject json, int index ) { if( json == null ) return null; JSONObject prm = getParam( json, index, "java.lang.Boolean" ); return prm.get( "value" ).isBoolean().booleanValue(); }
@Override public Object decode(JSONValue value) throws JsonEncoderDecoder.DecodingException { if (value instanceof JSONNumber) { return ((JSONNumber) value).doubleValue(); } else if (value instanceof JSONBoolean) { return ((JSONBoolean) value).booleanValue(); } else if (value instanceof JSONString) { return ((JSONString) value).stringValue(); } else if (value instanceof JSONArray) { JSONArray array = value.isArray(); List<Object> list = new ArrayList<Object>(array.size()); for (int ct = 0; ct < array.size(); ct++) { list.add(decode(array.get(ct))); } return list; } else if (value instanceof JSONObject) { JSONObject object = value.isObject(); Map<String, Object> map = new HashMap<String, Object>(); for (String key : object.keySet()) { map.put(key, decode(object.get(key))); } return map; } else { return null; } }
@Override public Boolean decode(JSONValue value) throws DecodingException { if (value == null || value.isNull() != null) { return null; } JSONBoolean bool = value.isBoolean(); if (bool == null) { throw new DecodingException("Expected a json boolean, but was given: " + value); } return bool.booleanValue(); }
@Override public void setValue(JSONValue value) { if (value != null && value.isBoolean() != null) { propertyValueBox.setValue(value.isBoolean().booleanValue()); } }
@Override public Picture create(final JSONObject node, final ValidationContext ctx) throws ValidationException { final Picture picture = new Picture(node, ctx); JSONValue jval = node.get("filter"); if (null != jval) { final JSONObject object = jval.isObject(); if (null != object) { JSONDeserializer.get().deserializeFilters(picture, object, ctx); jval = object.get("active"); final JSONBoolean active = jval.isBoolean(); if (null != active) { picture.setFiltersActive(active.booleanValue()); } } } return picture; }
public static Boolean getParameterboolean( JSONObject json, int index ) { if( json == null ) return null; JSONObject prm = getParam( json, index, "java.lang.Boolean" ); return prm.get( "value" ).isBoolean().booleanValue(); }
@Override public Boolean deserialize(final JSONValue jsonValue) { if (jsonValue == null || jsonValue.isNull() != null) { return null; } final JSONBoolean jsonBoolean = jsonValue.isBoolean(); if (jsonBoolean != null) { return jsonBoolean.booleanValue(); } final JSONString jsonString = jsonValue.isString(); if (jsonString != null) { if (jsonString.stringValue().isEmpty()) { return null; } return Boolean.valueOf(jsonString.stringValue()); } throw new GWTPojoSerializerException("Unable to deserialize " + jsonValue.toString() + " as Boolean"); } }
public Boolean getBooleanValueFor(EditorProperties property) { JSONValue jsonValue = getJsonValueFor(property); if (jsonValue == null) { return null; } JSONBoolean jsonBoolean = jsonValue.isBoolean(); if (jsonBoolean == null) { return null; } return jsonBoolean.booleanValue(); }
@Override public Picture create(final JSONObject node, final ValidationContext ctx) throws ValidationException { final Picture picture = new Picture(node, ctx); JSONValue jval = node.get("filter"); if (null != jval) { final JSONObject object = jval.isObject(); if (null != object) { JSONDeserializer.get().deserializeFilters(picture, object, ctx); jval = object.get("active"); final JSONBoolean active = jval.isBoolean(); if (null != active) { picture.setFiltersActive(active.booleanValue()); } } } return picture; }
/** * Get a boolean value from a {@link JSONObject}. * * @param jsonObject The object to get the key value from. * @param key The name of the key to search the value for. * @return Returns the value for the key in the object . * @throws JSONException Thrown in case the key could not be found in the JSON object. */ public static Boolean getBooleanValue(JSONObject jsonObject, String key) throws JSONException { checkArguments(jsonObject, key); JSONValue value = jsonObject.get(key); Boolean result = null; if (value != null && value.isBoolean() != null) { return ((JSONBoolean) value).booleanValue(); } return result; }
@Override public String deserialize(final JSONValue jsonValue) { if (jsonValue == null || jsonValue.isNull() != null) { return null; } final JSONString jsonString = jsonValue.isString(); if (jsonString != null) { return jsonString.stringValue(); } final JSONNumber jsonNumber = jsonValue.isNumber(); if (jsonNumber != null) { return Double.toString(jsonNumber.doubleValue()); } final JSONBoolean jsonBoolean = jsonValue.isBoolean(); if (jsonBoolean != null) { return Boolean.toString(jsonBoolean.booleanValue()); } throw new GWTPojoSerializerException("Unable to deserialize " + jsonValue.toString() + " as String"); } }
/** * Creates one of implementations of {@link EditorPropertyWidget}. * * @return an instance of {@link EditorPropertyWidget} */ public EditorPropertyWidget create(@NotNull String propertyName, @NotNull JSONValue value) { if (value.isBoolean() != null) { return new EditorBooleanPropertyWidget(propertyName, value.isBoolean().booleanValue()); } if (value.isNumber() != null) { Double doubleValue = value.isNumber().doubleValue(); return new EditorNumberPropertyWidget(propertyName, doubleValue.intValue()); } return new EditorStringPropertyWidget(propertyName, value.toString()); } }
@Override public Picture create(final JSONObject node, final ValidationContext ctx) throws ValidationException { final Picture picture = new Picture(node, ctx); JSONValue jval = node.get("filter"); if (null != jval) { final JSONObject object = jval.isObject(); if (null != object) { JSONDeserializer.get().deserializeFilters(picture, object, ctx); jval = object.get("active"); final JSONBoolean active = jval.isBoolean(); if (null != active) { picture.setFiltersActive(active.booleanValue()); } } } return picture; }
private static ColumnView parseColumn(int rowsCount, JSONObject jsonColumn) { String storage = jsonColumn.get("storage").isString().stringValue(); String typeName = jsonColumn.get("type").isString().stringValue(); ColumnType type = ColumnType.valueOf(typeName); return new ColumnArrayView(type, jsonColumn.get("values").isArray().getJavaScriptObject()); case "empty": return new EmptyColumnView(type, rowsCount); JSONBoolean jsonBoolean = jsonValue.isBoolean(); if(jsonBoolean == null) { return ConstantColumnView.nullBoolean(rowsCount); } else { return new ConstantColumnView(rowsCount, jsonValue.isBoolean().booleanValue());