diff options
| author | Jean Boussier <jean.boussier@gmail.com> | 2025-08-23 19:57:14 +0200 |
|---|---|---|
| committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2025-08-27 10:01:52 +0900 |
| commit | d9e9a667a8c8fb6f57611c68b45eaf1f2c39fca1 (patch) | |
| tree | 3ac8241bb5b0bc69574d2496324e0ec14a730731 /node_dump.c | |
| parent | 0e0f0dfd070fc156ec74c58f44d86a884a0580e0 (diff) | |
JSON.generate: warn or raise on duplicated key
Because both strings and symbols keys are serialized the same,
it always has been possible to generate documents with duplicated
keys:
```ruby
>> puts JSON.generate({ foo: 1, "foo" => 2 })
{"foo":1,"foo":2}
```
This is pretty much always a mistake and can cause various
issues because it's not guaranteed how various JSON parsers
will handle this.
Until now I didn't think it was possible to catch such case without
tanking performance, hence why I only made the parser more strict.
But I finally found a way to check for duplicated keys cheaply enough.
Diffstat (limited to 'node_dump.c')
0 files changed, 0 insertions, 0 deletions
