News for hackers. Stuff that matters.
Re:Jsonnet – The Data Templating Language by spion on Monday March 27, 2023 @02:25PM (#35330322)
What would you use instead?
Re:Jsonnet – The Data Templating Language by techhazard on Monday March 27, 2023 @04:17PM (#35331849)
Not OP, but I can highly recommend just using the programming language you already use to make key-value map to and then converting that to JSON. That way you only have 1 syntax to worry about. In my case that’s Python (using dictionaries and json.dumps)

You could also try for a templating framework (like jinja2) but then you have 3 syntaxes colliding: the programming language you call the templating engine with (e.g. Python for jinja2) the templating language itself (e.g. jinja2) and then JSON as well.

Re:Jsonnet – The Data Templating Language by spion on Monday March 27, 2023 @05:22PM (#35332845)
This works for some languages but not others (some typed languages are particularly ill-suited to the problem of writing CLI tools to dump heterogenous dictionaries and/or objects with many optional fields)
Re:Jsonnet – The Data Templating Language by GlickWick on Tuesday March 28, 2023 @10:56AM (#35342115)
Assuming you need something beyond basic JSON, a well-understood scripting language like JS or Python. Bazel if you want something more build-focused.