Search code examples
jsongrails

How to handle post a BigInteger in JSONObject in grails controller?


Here is my example:

class MyController {

    def index() {
        JSONObject json = request.JSON
        log.info('{}', json)
        respond json
    }

}

How do I handle BigInteger in json? like this:

curl -H 'content-type: application/json' -d '{"largeNum": 99999999999999999999999}' http://localhost:8080/

The JSONObject will conver this largeNum to Double like this:

{"largeNum":9.999999999999999E22}

But I want to get a BigInteger, how to?


Solution

  • Thank you guys. I push a PR to solve this issue: https://github.com/grails/grails-core/pull/11334

    Waiting the upstream to be merged.