@nicolasparada/json-bigint

    0.5.0 • Public • Published

    JSON BigInt

    JavaScript library that allows encoding JSON with BigInt support.

    JavaScript doesn't work with numbers too big. If you are working with 64-bit integers in your server, this library got you covered.

    No dependencies. 443 bytes.

    Example

    import JSONBigInt from 'https://unpkg.com/@nicolasparada/json-bigint@0.5.0/json-bigint.js'
    
    const input = '{"big":9223372036854775807,"small":123}'
    console.log('input:', input)
    
    const r1 = JSON.parse(input)
    console.group('built-in JSON')
    console.log('parsed:', r1)
    console.log('stringified:', JSON.stringify(r1))
    console.groupEnd()
    
    const r2 = JSONBigInt.parse(input)
    console.group('JSONBigInt')
    console.log('parsed:', r2)
    console.log('stringified:', JSONBigInt.stringify(r2))
    console.groupEnd()
    input: {"big":9223372036854775807,"small":123}
    
    built-in JSON
        parsed: { big: 9223372036854776000, small: 123 }
        stringified: {"big":9223372036854776000,"small":123}
    
    JSONBigInt
        parsed: { big: 9223372036854775807n, small: 123 }
        stringified: {"big":9223372036854775807,"small":123}
    

    Install

    npm i @nicolasparada/json-bigint

    DownloadsWeekly Downloads

    22

    Version

    0.5.0

    License

    ISC

    Unpacked Size

    3.61 kB

    Total Files

    4

    Last publish

    Collaborators

    • nicolasparada