3 ms·
No. Neither. No. It's the same as whitespace. You don't expect it to be round-trippable, it's just to make the source file easier to read. Likewise I would int
by Asraelite 2y ago
No. Neither. No.
It's the same as whitespace. You don't expect it to be round-trippable, it's just to make the source file easier to read. Likewise I would interpret any expectation of the preservation of comments the same as an expectation of the preservation of whitespace: weird, unreasonable, and probably arising from a misunderstanding of how JSON works.
- jon_richards 2y agoYeah. A round-trippable comment is just another text field. Leave that to the application. It’s unfortunate how many APIs are documented with a single json example, but annotating them with comments (and maybe types?) would help immensely.
- eadmund 2y agoIf an application stores its configuration in JSON, and I edit it by hand and leave a commented ‘// I did this because the other way was broken,’ then I open the application and change the configuration there … then I expect my comment to survive. XML preserved whitespace, too! I dislike XML intensely, but there was a method to its madness. There’s a method to JSON, too: simplicity and usability. You start adding things to JSON, you lose that.