/** * Returns the JSON string for this value in its minimal form, without any additional whitespace. * The result is guaranteed to be a valid input for the method {@link Json#parse(String)} and to * create a value that is <em>equal</em> to this object. * * @return a JSON string that represents this value */ @Override public String toString() { return toString(WriterConfig.MINIMAL); }
/** * Returns this JSON value as {@link JsonObject}, assuming that this value represents a JSON * object. If this is not the case, an exception is thrown. * * @return a JSONObject for this value * @throws UnsupportedOperationException * if this value is not a JSON object */ public JsonObject asObject() { throw new UnsupportedOperationException("Not an object: " + toString()); }
/** * Returns this JSON value as {@link JsonArray}, assuming that this value represents a JSON array. * If this is not the case, an exception is thrown. * * @return a JSONArray for this value * @throws UnsupportedOperationException * if this value is not a JSON array */ public JsonArray asArray() { throw new UnsupportedOperationException("Not an array: " + toString()); }
/** * Returns this JSON value as a <code>boolean</code> value, assuming that this value is either * <code>true</code> or <code>false</code>. If this is not the case, an exception is thrown. * * @return this value as <code>boolean</code> * @throws UnsupportedOperationException * if this value is neither <code>true</code> or <code>false</code> */ public boolean asBoolean() { throw new UnsupportedOperationException("Not a boolean: " + toString()); }
/** * Returns this JSON value as String, assuming that this value represents a JSON string. If this * is not the case, an exception is thrown. * * @return the string represented by this value * @throws UnsupportedOperationException * if this value is not a JSON string */ public String asString() { throw new UnsupportedOperationException("Not a string: " + toString()); }
/** * Returns this JSON value as a <code>float</code> value, assuming that this value represents a * JSON number. If this is not the case, an exception is thrown. * <p> * If the JSON number is out of the <code>Float</code> range, {@link Float#POSITIVE_INFINITY} or * {@link Float#NEGATIVE_INFINITY} is returned. * </p> * * @return this value as <code>float</code> * @throws UnsupportedOperationException * if this value is not a JSON number */ public float asFloat() { throw new UnsupportedOperationException("Not a number: " + toString()); }
/** * Returns this JSON value as a <code>double</code> value, assuming that this value represents a * JSON number. If this is not the case, an exception is thrown. * <p> * If the JSON number is out of the <code>Double</code> range, {@link Double#POSITIVE_INFINITY} or * {@link Double#NEGATIVE_INFINITY} is returned. * </p> * * @return this value as <code>double</code> * @throws UnsupportedOperationException * if this value is not a JSON number */ public double asDouble() { throw new UnsupportedOperationException("Not a number: " + toString()); }
/** * Returns this JSON value as an <code>int</code> value, assuming that this value represents a * JSON number that can be interpreted as Java <code>int</code>. If this is not the case, an * exception is thrown. * <p> * To be interpreted as Java <code>int</code>, the JSON number must neither contain an exponent * nor a fraction part. Moreover, the number must be in the <code>Integer</code> range. * </p> * * @return this value as <code>int</code> * @throws UnsupportedOperationException * if this value is not a JSON number * @throws NumberFormatException * if this JSON number can not be interpreted as <code>int</code> value */ public int asInt() { throw new UnsupportedOperationException("Not a number: " + toString()); }
/** * Returns this JSON value as a <code>long</code> value, assuming that this value represents a * JSON number that can be interpreted as Java <code>long</code>. If this is not the case, an * exception is thrown. * <p> * To be interpreted as Java <code>long</code>, the JSON number must neither contain an exponent * nor a fraction part. Moreover, the number must be in the <code>Long</code> range. * </p> * * @return this value as <code>long</code> * @throws UnsupportedOperationException * if this value is not a JSON number * @throws NumberFormatException * if this JSON number can not be interpreted as <code>long</code> value */ public long asLong() { throw new UnsupportedOperationException("Not a number: " + toString()); }
/** * Returns the JSON string for this value in its minimal form, without any additional whitespace. * The result is guaranteed to be a valid input for the method {@link Json#parse(String)} and to * create a value that is <em>equal</em> to this object. * * @return a JSON string that represents this value */ @Override public String toString() { return toString(WriterConfig.MINIMAL); }
/** * Returns the JSON string for this value in its minimal form, without any additional whitespace. * The result is guaranteed to be a valid input for the method {@link #readFrom(String)} and to * create a value that is <em>equal</em> to this object. * * @return a JSON string that represents this value */ @Override public String toString() { return toString(WriterConfig.MINIMAL); }
/** * Returns this JSON value as {@link JsonObject}, assuming that this value represents a JSON * object. If this is not the case, an exception is thrown. * * @return a JSONObject for this value * @throws UnsupportedOperationException * if this value is not a JSON object */ public JsonObject asObject() { throw new UnsupportedOperationException("Not an object: " + toString()); }
/** * Returns this JSON value as String, assuming that this value represents a JSON string. If this * is not the case, an exception is thrown. * * @return the string represented by this value * @throws UnsupportedOperationException * if this value is not a JSON string */ public String asString() { throw new UnsupportedOperationException("Not a string: " + toString()); }
/** * Returns this JSON value as {@link JsonArray}, assuming that this value represents a JSON array. * If this is not the case, an exception is thrown. * * @return a JSONArray for this value * @throws UnsupportedOperationException * if this value is not a JSON array */ public JsonArray asArray() { throw new UnsupportedOperationException("Not an array: " + toString()); }
/** * Returns this JSON value as String, assuming that this value represents a JSON string. If this * is not the case, an exception is thrown. * * @return the string represented by this value * @throws UnsupportedOperationException * if this value is not a JSON string */ public String asString() { throw new UnsupportedOperationException("Not a string: " + toString()); }
/** * Returns this JSON value as a <code>boolean</code> value, assuming that this value is either * <code>true</code> or <code>false</code>. If this is not the case, an exception is thrown. * * @return this value as <code>boolean</code> * @throws UnsupportedOperationException * if this value is neither <code>true</code> or <code>false</code> */ public boolean asBoolean() { throw new UnsupportedOperationException("Not a boolean: " + toString()); }
private ImmutableJsonString(final com.eclipsesource.json.JsonValue toWrap) { super(toWrap); if (!toWrap.isString()) { throw new IllegalArgumentException("Is not a string: " + toWrap.toString()); } }
/** * Deep convert to JSON and return it's string representation. See @toJson for details. * * @param value * object to convert. Anything that could be converted to JSON. * * @return string value with packed JSON representaton */ static public String toJsonString(Object value) { return toJson(value).toString(); }
public synchronized String getBalanceForAddress(String address) throws WalletCallException, IOException, InterruptedException { JsonValue response = this.executeCommandAndGetJsonValue("z_getbalance", wrapStringParameter(address)); return String.valueOf(response.toString()); }
private JsonArray executeCommandAndGetJsonArray(String command1, String command2, String command3) throws WalletCallException, IOException, InterruptedException { JsonValue response = this.executeCommandAndGetJsonValue(command1, command2, command3); if (response.isArray()) { return response.asArray(); } else { throw new WalletCallException("Unexpected non-array response from wallet: " + response.toString()); } }