Hacker News new | ask | show | jobs
by IanCal 4698 days ago
> Salient point is that you would need to ensure that you are only using JSON parsers that tolerate duplicate names (and use the last value)

To drive this home a bit more forcefully, it requires knowing the behaviour of your parser where it is marked as "undefined" in the spec.

If that isn't enough to stop you, DON'T USE JSON. A patch level change in a library could break your code in a non-obvious way and it would be your fault. If you want comments, DON'T USE JSON, JSON DOESN'T HAVE THEM.

1 comments

Note that if your parser is the ES-standard JSON.parse, then the behavior here is in fact defined by ES5 section 15.12.2, even with duplicate names.