-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
JSON.getLong produces inconsistent results #332
Comments
we don't have a version 2.0. All our versions are dates. Are you sure you are using this library? |
I added a test for this that looks like this against our current code base: @Test
public void testLongFromString(){
String str = "26315000000253009";
JSONObject json = new JSONObject();
json.put("key", str);
final Object actualKey = json.opt("key");
assert str.equals(actualKey) : "Incorrect key value. Got " + actualKey
+ " expected " + str;
final long actualLong = json.optLong("key");
assert actualLong != 0 : "Unable to extract long value for string " + str;
assert 26315000000253009L == actualLong : "Incorrect key value. Got "
+ actualLong + " expected " + str;
final String actualString = json.optString("key");
assert str.equals(actualString) : "Incorrect key value. Got "
+ actualString + " expected " + str;
} All the tests pass. I'm guessing you are using a different library. |
You can see a list of our recent releases here: or from Maven here: Please try updating to the latest version and if using Maven, Gradle, Ant, etc., ensure you have the proper group and artifact ids. Many people have forked this project over it's long life and some are not supported well. |
Sounds like this is resolved due to behavior not matching our released code. But let me know if you think it should be reopened. |
Json.getLong produces inconsistent results. Here is the following sample snippet which produces different results across different machine with the same JDK version and same JSON jar
Different results
JSON version : 2.0
MD5Sum value of Json jar : 2f7f899f0766e65017744a4c4fc14d46
JDK Version : 1.8.0_92
What could be the reason for this inconsistent results? It would be great help if someone could help me know about this.
json.jar.zip
This is the json.jar which I'm using.
The text was updated successfully, but these errors were encountered: