this post was submitted on 08 Sep 2024
1235 points (98.3% liked)

Programmer Humor

32712 readers
1542 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 13 points 3 months ago* (last edited 3 months ago) (2 children)
{ "key": "six",
  "value": 6,
  "comment": "6 is a bad number. Use five." }
[–] [email protected] 28 points 3 months ago* (last edited 3 months ago) (1 children)

[This comment has been deleted by an automated system]

[–] [email protected] 2 points 3 months ago* (last edited 3 months ago)

Yes, it's a field. Specifically, a field containing human-readable information about what is going on in adjacent fields, much like a comment. I see no issue with putting such information in a json file.

As for "you don't comment by putting information in variables": In Python, your objects have the __doc__ attribute, which is specifically used for this purpose.

[–] [email protected] 17 points 3 months ago

Please don't. If you need something like json but with comments, then use YAML or TOML. Those formats are designed to be human-readable by default, json is better suited for interchanging information between different pieces of software. And if you really need comments inside JSON, then find a parser that supports // or /* */ syntax.