Hi there,

The toJSON method of BigNum is currently returning a string with quotation 
marks around it: 
https://github.com/apache/arrow/blob/fbb781bcdd15d54c52c71881c5c53d0c68069be6/js/src/util/bn.ts#L39

JSON.stringify will include those quotation marks in the output JSON. Here’s an 
example illustrating the issue:

const a = BN.new([12])
console.log(JSON.stringify({ a }))
> {"a":"\"12\""}

Our usecase is to take some arrow data and return it to a web client as json – 
but because the format is bad we’re having to work around this by converting 
all BigNums to strings before serilaizing the response.

Is BigNum.toJSON intended to work with JSON.stringify? Happy to open a PR if so.

Best,
Sam 

Reply via email to