A Case for JSON6 ================ :category: Misc :date: 2025-04-19 06:43:00 +0300 :tags: configuration, json, json5, json6 Just a required follow up `for the previous post `_: JSON5 sucks too, like any other possible format. Just look at this: .. _json5: link://slug/json5 .. code-block:: javascript { certificate: "\ -----BEGIN PRIVATE KEY-----\n\ MIIBVQIBADANBgkqhkiG9w0BAQEFAASCAT8wggE7AgEAAkEAt6wGEsfdarMo9KET\n\ sNv9gpBWkGfhIq3/Jhr14+3d8TXprmTk/XWReo5DA3+SbB7ebF3xUtN/4K5lUkcG\n\ 1AbdywIDAQABAkBuMbfnFqAhvuFoeydMKYAcECrPMnOhEdENdIlnuTM53kBf18f/\n\ KaWRWv8ViuZ31GpArY8cBzj0YG30vE49Il8ZAiEA7PpotzcpjNcMKnwEBm3q0c6H\n\ 3RRZD6i32Q/vXcQBeB0CIQDGaj4BJ/fuqiHvKzetfjhpOD+sYr3VDgEyjTcojhzZ\n\ BwIgTBRYafmbrUuc7EbERAwlxxW3KJLPxOc1nsou3rt+fUECIQCjBGUfJAyDDUtG\n\ KpbbN0n3wRwncRUQuCnps7Zu3pv6/wIhAIIcKty7O0T7auctlpMSdyw6vp0w818x\n\ namFjg3cbBs4\n\ -----END PRIVATE KEY-----\n" } .. TEASER_END Notice these ``"\n\"``. Arguably such stuff does not belong in configs, but it's not always possible to avoid it. Just to compare, let's look at the others. TOML wouldn't allow indentation too but at least it is structured in such a way so you can avoid indentation entirely: .. code-block:: toml certificate = ''' -----BEGIN PRIVATE KEY----- MIIBVQIBADANBgkqhkiG9w0BAQEFAASCAT8wggE7AgEAAkEAt6wGEsfdarMo9KET sNv9gpBWkGfhIq3/Jhr14+3d8TXprmTk/XWReo5DA3+SbB7ebF3xUtN/4K5lUkcG 1AbdywIDAQABAkBuMbfnFqAhvuFoeydMKYAcECrPMnOhEdENdIlnuTM53kBf18f/ KaWRWv8ViuZ31GpArY8cBzj0YG30vE49Il8ZAiEA7PpotzcpjNcMKnwEBm3q0c6H 3RRZD6i32Q/vXcQBeB0CIQDGaj4BJ/fuqiHvKzetfjhpOD+sYr3VDgEyjTcojhzZ BwIgTBRYafmbrUuc7EbERAwlxxW3KJLPxOc1nsou3rt+fUECIQCjBGUfJAyDDUtG KpbbN0n3wRwncRUQuCnps7Zu3pv6/wIhAIIcKty7O0T7auctlpMSdyw6vp0w818x namFjg3cbBs4 -----END PRIVATE KEY----- ''' YAML shines. `In all that string mess `_, there is a perfect solution for this specific use case: .. _yaml: link://slug/toml-yaml .. code-block:: yaml certificate: | -----BEGIN PRIVATE KEY----- MIIBVQIBADANBgkqhkiG9w0BAQEFAASCAT8wggE7AgEAAkEAt6wGEsfdarMo9KET sNv9gpBWkGfhIq3/Jhr14+3d8TXprmTk/XWReo5DA3+SbB7ebF3xUtN/4K5lUkcG 1AbdywIDAQABAkBuMbfnFqAhvuFoeydMKYAcECrPMnOhEdENdIlnuTM53kBf18f/ KaWRWv8ViuZ31GpArY8cBzj0YG30vE49Il8ZAiEA7PpotzcpjNcMKnwEBm3q0c6H 3RRZD6i32Q/vXcQBeB0CIQDGaj4BJ/fuqiHvKzetfjhpOD+sYr3VDgEyjTcojhzZ BwIgTBRYafmbrUuc7EbERAwlxxW3KJLPxOc1nsou3rt+fUECIQCjBGUfJAyDDUtG KpbbN0n3wRwncRUQuCnps7Zu3pv6/wIhAIIcKty7O0T7auctlpMSdyw6vp0w818x namFjg3cbBs4 -----END PRIVATE KEY----- So JSON6_ should bring it at least to the TOML level: .. code-block:: javascript { certificate: ` -----BEGIN PRIVATE KEY----- MIIBVQIBADANBgkqhkiG9w0BAQEFAASCAT8wggE7AgEAAkEAt6wGEsfdarMo9KET sNv9gpBWkGfhIq3/Jhr14+3d8TXprmTk/XWReo5DA3+SbB7ebF3xUtN/4K5lUkcG 1AbdywIDAQABAkBuMbfnFqAhvuFoeydMKYAcECrPMnOhEdENdIlnuTM53kBf18f/ KaWRWv8ViuZ31GpArY8cBzj0YG30vE49Il8ZAiEA7PpotzcpjNcMKnwEBm3q0c6H 3RRZD6i32Q/vXcQBeB0CIQDGaj4BJ/fuqiHvKzetfjhpOD+sYr3VDgEyjTcojhzZ BwIgTBRYafmbrUuc7EbERAwlxxW3KJLPxOc1nsou3rt+fUECIQCjBGUfJAyDDUtG KpbbN0n3wRwncRUQuCnps7Zu3pv6/wIhAIIcKty7O0T7auctlpMSdyw6vp0w818x namFjg3cbBs4 -----END PRIVATE KEY-----`, } Still, I don't believe that all planned features are good there, JSON6_ aggressively ditches simplicity for syntax sugar. .. _JSON6: https://github.com/d3x0r/JSON6 Needless to say, even the top file here is better than raw JSON, where multiline representation for strings is not possible at all.