Actions
Bug #19686
closedBigDecimal object returns JSON string
Bug #19686:
BigDecimal object returns JSON string
Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-darwin21]
Description
Hi,
When I call the to_json method to the BigDecimal object, it returns a JSON string.
Is this intentional?
> ruby -v -rbigdecimal -rjson -e 'p BigDecimal("1.2").to_json'
ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-darwin21]
"\"0.12e1\""
> ruby -v -rjson/add/bigdecimal -e 'p BigDecimal("1.2").to_json'
ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-darwin21]
"{\"json_class\":\"BigDecimal\",\"b\":\"18:0.12e1\"}"
I expect a JSON number like "0.12e1".
Actions