public String stringify(JsonValue value) { if (!value.isNumber()) return null; double val=value.asDouble(); if (val==Double.POSITIVE_INFINITY) return "Inf"; else if (val==Double.NEGATIVE_INFINITY) return "-Inf"; else if (Double.isNaN(val)) return "NaN"; else if (val==0.0 && 1/val==Double.NEGATIVE_INFINITY) return "-0"; else return null; } }
public String stringify(JsonValue value) { if (!value.isNumber()) return null; double val=value.asDouble(); if (val==Double.POSITIVE_INFINITY) return "Inf"; else if (val==Double.NEGATIVE_INFINITY) return "-Inf"; else if (Double.isNaN(val)) return "NaN"; else if (val==0.0 && 1/val==Double.NEGATIVE_INFINITY) return "-0"; else return null; } }
/** * Returns the <code>double</code> value of the member with the specified name in this object. If * this object does not contain a member with this name, the given default value is returned. If * this object contains multiple members with the given name, the last one will be picked. If this * member's value does not represent a JSON number or if it cannot be interpreted as Java * <code>double</code>, an exception is thrown. * * @param name * the name of the member whose value is to be returned * @param defaultValue * the value to be returned if the requested member is missing * @return the value of the last member with the specified name, or the given default value if * this object does not contain a member with that name */ public double getDouble(String name, double defaultValue) { JsonValue value=get(name); return value!=null ? value.asDouble() : defaultValue; }
/** * Returns the <code>double</code> value of the member with the specified name in this object. If * this object does not contain a member with this name, the given default value is returned. If * this object contains multiple members with the given name, the last one will be picked. If this * member's value does not represent a JSON number or if it cannot be interpreted as Java * <code>double</code>, an exception is thrown. * * @param name * the name of the member whose value is to be returned * @param defaultValue * the value to be returned if the requested member is missing * @return the value of the last member with the specified name, or the given default value if * this object does not contain a member with that name */ public double getDouble(String name, double defaultValue) { JsonValue value=get(name); return value!=null ? value.asDouble() : defaultValue; }
public String stringify(JsonValue value) { if (stringify && value.isNumber() && value.asLong()==value.asDouble()) { return "0x"+Long.toHexString(value.asLong()); } else { return null; } } }
public String stringify(JsonValue value) { if (stringify && value.isNumber() && value.asLong()==value.asDouble()) { return "0x"+Long.toHexString(value.asLong()); } else { return null; } } }
Object convertJsonToJava(final JsonValue value) throws PersistentStoreException { if (null == value) { return null; } else if (value.isString()) { return value.asString(); } else if (value.isNumber()) { return value.asDouble(); } else if (value.isBoolean()) { return value.asBoolean(); } else if (value.isArray()) { final List<Object> list = new ArrayList<>(); for (final JsonValue av : value.asArray()) { final Object o = this.convertJsonToJava(av); list.add(o); } return list; } else if (value.isObject()) { final Map<String, Object> map = new HashMap<>(); for (final String k : value.asObject().names()) { final JsonValue jv = value.asObject().get(k); final Object v = this.convertJsonToJava(jv); map.put(k, v); } return map; } else { throw new PersistentStoreException("Unknown JSON type.", null); } }
return t; } else if (value.isNumber()) { final T t = this.af.createDatatype(itemType, value.asDouble()); return t; } else if (value.isBoolean()) {