Skip to content

Conversation

@tkissing
Copy link

See the updated "test" why this is useful :)

@sidorares
Copy link
Owner

Not sure if you really need this in the package - if you need stringified ints instead of BigNumber's you can add reviver in your own code, it's just 3 lines function as you demonstrated.

My biggest concern is that you proposing to change JSON.parse api ( probably in backward compartible way, but still). Please convince me with real life examples :)

Also, if you really want to help with this project - could you make a proper test suite out of test.js ( preferably using mocha )

anyway, thanks for your suggestion and waiting for more discussion

@KeKs0r
Copy link

KeKs0r commented Sep 24, 2015

@sidorares
I actually have a use case where I need to sent a BigInt to an API. And somehow I can't construct it without this PR.

thats my test that only passes with @tkissing changes:

    describe('BigINt', {only:true},function(){
        it('is the same', function(done){
            var JSONbig = require('json-bigint');
            var BigNumber = require('bignumber.js');
            var input = '{"id":40564371973213694,"custom_id":"2"}';
            var parsed = JSONbig.parse(input);
            var output = JSONbig.stringify(parsed);
            expect(input).equal(output);

            var ownJSON = {
                id: new BigNumber("40564371973213694"),
                custom_id: "2"
            };
            var outOwn = JSONbig.stringify(ownJSON);
            expect(outOwn).equal(input);
            done();
        });
    });

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants