mirror of
https://github.com/voson-wang/toon.git
synced 2026-01-29 23:34:10 +08:00
feat: toJSON method support for custom serialization (#237)
* feat: add toJSON method support for custom serialization * fix: prevent infinite recursion * test: remove redundant toJSON test cases * docs: add custom serialization details for toJSON method * test: fix type issues --------- Co-authored-by: Johann Schopplich <mail@johannschopplich.com>
This commit is contained in:
@@ -54,6 +54,7 @@ Non-JSON-serializable values are normalized before encoding:
|
||||
|
||||
| Input | Output |
|
||||
|-------|--------|
|
||||
| `Object` with `toJSON()` method | Result of calling `toJSON()`, recursively normalized |
|
||||
| Finite number | Canonical decimal (no exponent, no leading/trailing zeros: `1e6` → `1000000`, `-0` → `0`) |
|
||||
| `NaN`, `Infinity`, `-Infinity` | `null` |
|
||||
| `BigInt` (within safe range) | Number |
|
||||
|
||||
Reference in New Issue
Block a user