thiagowfx's avatar

Β¬ just serendipity πŸ€ (not just serendipity)

Hacking comments with JSON

β€’ 98 words β€’ 1 min β€’ updated

Hacking Comments Into JSON by Marko Kamner:

JSON does not natively support comments, which is OK, but sometimes a comment could really help.

If the application loading the JSON does not care about additional keys we can simply add a key with our favorite comment indicator like // or #.

json
{
  "//": "This setting enables not just A, but somehow also B",
  "enable_feature_a": true
}

Silly, but clever.

Alternatively: look into JSON5 (“JSON for Humans”), or JSONC (“JSON with comments”), or HJSON (“a user interface for JSON”), or jsonl (“JSON Lines”).

Obligatory:

Fortunately, the charging one has been solved now that we've all standardized on mini-USB. Or is it micro-USB? Shit.

XKCD Courtesy of Randall Munroe