bellard / quickjs

Public repository of the QuickJS Javascript Engine.
https://bellard.org/quickjs
Other
8.52k stars 892 forks source link

Support for JSON.rawJSON #365

Open chrisdickinson opened 2 weeks ago

chrisdickinson commented 2 weeks ago

Hi! Thanks for the great project! I'm opening an issue because I ran into a situation where I need to JSON.stringify an object containing a bigint. I can bail out back to parsing to/from strings, but it looks like one (forward-looking) way to accomplish this is via JSON.rawJSON, by doing something like:

JSON.stringify(
  {"bigint": 9223372036854775807n},
  (key, value) => typeof value === 'bigint' ? JSON.rawJSON(value.toString()) : value
)

It might be a bit soon to implement but I wanted to get the proposal on your radar!