Skip to content

nicolasparada/js-json-bigint

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JSON BigInt

JavaScript library that allows encoding JSON with BigInt support.

JavaScript JSON API doesn't work with numbers too big. If you are working with 64-bit integers in your server, this library got you covered. 64-bits integers will be parsed as bigint 😉

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}
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy