Skip to content

Large integers do not work #157

Description

@effad

The following piece of code surprisingly outputs class java.lang.String, instead of a number-class like BigDecimal or BigInteger.

import org.json.JSONException;
import org.json.JSONObject;


public class CodeTest {

    public static void main(String[] args) throws JSONException {
        String str = "{\"number_value\":9223372036854776000}";
        JSONObject x = new JSONObject(str);
        System.out.println(x.get("number_value").getClass());
    }
}

Since JSON does not limit the size of numbers (to the best of my knowledge) I consider this to be a bug.
The culprit is JSONObject.stringToValue which will not work with numbers beyond the range of Java Long.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions