4 ms·
In most applications reading and writing JSON are completely separate operations and roundtripping comments makes no sense. Actual JSON-reading applications mu
by HelloNurse 6y ago
In most applications reading and writing JSON are completely separate operations and roundtripping comments makes no sense.
Actual JSON-reading applications must ignore comments because they aren't allowed to care about them. On the other hand anything useful can be placed in a proper field, a comment would be a hack to pass information to human readers but not to JSON consumers (saving some time and memory).
Such a technique could only be considered if people are supposed to read the JSON files and some information is useful for them but not for the reading application: a niche within a niche.
Preserving comments would actually be a complicated special purpose feature, reserved for something like structured text editors that can perform nonstandard parsing with comments included in their special object model (of the large Javascript subset/superset/variant they choose to support and roundtrip, not of JSON).