• tetris11@lemmy.ml
    link
    fedilink
    arrow-up
    18
    arrow-down
    5
    ·
    edit-2
    2 months ago
    { "key": "six",
      "value": 6,
      "comment": "6 is a bad number. Use five." }
    
      • thebestaquaman@lemmy.world
        link
        fedilink
        arrow-up
        2
        ·
        edit-2
        2 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.

    • renzev@lemmy.worldOP
      link
      fedilink
      English
      arrow-up
      16
      ·
      2 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.