News for hackers. Stuff that matters.
Re:JSON as configuration files: please don’t (2016) by arp242 on Saturday April 13, 2019 @07:43PM (#19656522)
Author of the article here; I think this is a complex issue with no single "right" answer. It depend on the context and what you're doing with it.

I wrote this after getting annoyed with MediaWiki's new extension format which uses JSON files to set up the extension. What I wanted to do is not include some CSS if a certain plugin is loaded, and that's pretty much impossible to do in a declarative configuration file. Using a JSON file – or any other declarative config – to describe how code works is not a good idea IMHO (although it's probably fine to add basic metadata).

The worst case of declarative programming gone wrong that I've seen is probably k8s.

I can't really judge your Gradle example, as I've never worked with Gradle (or Java in general).

> I'm getting a bit fatigued of these you're-doing-it-wrong posts

I agree, and I would rename the article if I hadn't put the full title in the URL (I have since stopped doing that exactly because I wanted to rename this). In my defence, at the time I was annoyed with MediaWiki, PHP, this JSON stuff, and the reasons I even had to work on MediaWiki in the first place (which is a long story involving a lot of drama).

That being said, I think using JSON as a human-editable configuration format is, quite frankly, never a good application of the tool. I can't think of any cases where it's the best tool, chiefly due the lack of comments, but also because it's kind of a pain to write. Variants which allow comments – such as JSON5 – are okay, but that's no longer JSON.

There are no comments on this comment yet.