logoalt Hacker News

hombre_fatal12/09/20241 replyview on HN

People keep bringing it up that "anything can be abused" but the point is that if you want to abuse something, abuse the simple parseable data rather than comments in the syntax tree.

Your two examples are just two examples of why we don't need comments for data interchange: yes, you put the data in a trivial, stable position in the parsed data that all parsers can parse rather than write some sort of DSL that has to be extracted from comment nodes that may appear in various places in the tree.

Turning this:

    { "key": "value" /* directive */ }
Into this:

    { "key": { "value": "value", "info": "directive" } }
Is the whole point. The more "abusive" you imagine the contents of "directive" to be, the more reason it should exist as the latter data, not more reason we should accept the former.

Replies

Brian_K_White12/09/2024

The whole point is you can't just add your own new keys/values/fields.

Most json users are not writing all of the software that both generates and consumes the json.