Error occurred While try to parsing JSON String using java

后端 未结 3 1873
离开以前
离开以前 2020-12-21 12:14

I\'m trying to parse the JSON string using java. I don\'t know How to do that, I searched lot in internet and I got some idea. With that I have build code, but it doesn\'t w

3条回答
  •  北荒
    北荒 (楼主)
    2020-12-21 12:18

    18446744073709551615 is 2^64 and until Java 8 the maximum value of a long is 2^63 - 1 (which is 9223372036854775807). In Java 8, you can have an unsigned long which is 2^64 but then you're tying yourself to a specific minimum version of Java.

    Checking the source of org.json.simple.parser.JSONParser, etc, neither BigInteger nor BigDecimal are mentioned, so it looks like you'll need an alternative parser.

    Some JSON parsers give you explicit control over this behaviour, e.g. in Jackson you have

    mapper.enable(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
    mapper.enable(DeserializationFeature.USE_BIG_INTEGER_FOR_INTS);
    

    There's some useful information in this question too.

提交回复
热议问题