-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Invalid Amount is generated in JSON when AMount#fromString is used with drops #65
Comments
I guess you did Interesting, the JSON format for XRP is actually a string with the amount of drops (a million of make an XRP). It's unfortunate that XRP is specified in a different manner to issued currencies, and that there are fields, such as Typically you want to use the .toJSON() method which returns an Object, if you aren't sure if the Amount is native or not. @Override
public Object toJSON() {
if (isNative()) {
return toDropsString();
} else {
return toJSONObject();
}
}
public JSONObject toJSONObject() {
try {
JSONObject out = new JSONObject();
out.put("currency", currencyString());
out.put("value", valueText());
out.put("issuer", issuerString());
return out;
} catch (JSONException e) {
throw new RuntimeException(e);
}
}
public String toDropsString() {
if (!isNative()) {
throw new RuntimeException("Amount is not native");
}
return bigIntegerDrops().toString();
} Given that the Amount class must perform twin duties, maybe it makes sense for an exception to be thrown when |
Hi, your guess was correct. By using "toDropString" everything works fine. Thanks and Kind regards On Mon, Nov 24, 2014 at 10:18 AM, sublimator [email protected]
|
Ripple-java-lib is not correctly rendering in JSON amount expressed in drop. As an example, an Amount constructed through the following call:
renders through ripple-java-lib in
which is then rejected by the server:
The text was updated successfully, but these errors were encountered: