There's a real need for JSON templating languages not targeting developers. Tools like Zapier, Customer.io's webhooks, etc. allow integration with arbitrary APIs and have become a standard part of many marketing/sales stacks. These apps use things like Jinja, Mustache, or Liquid which are great for text but not JSON templates. Curly braces as primary delimiters, not allowing trailing commas on final elements, and oth…
Jsonnet – A data templating language
71–80 of 90 posts
Re: Jsonnet – A data templating language
#72Also check out https://dhall-lang.org It's GCL but with a strong type system and termination guarantees. I personally like the syntax a bit more than jsonnet. It's a bit less noisy. I'm also a bit biased because I work on https://github.com/dhall-lang/dhall-kubernetes . We're currently working on a 2.0 release so the current state of the repo is a bit in turmoil. Programmable configuration language like dhall an json…
Can dhall be compiled for Windows?
Re: Jsonnet – A data templating language
#73All the people suggesting to use JS instead of Jsonnet are completely missing the point. Jsonnet is a functional lazy evaluated language that supports powerful referential concepts. Unfortunately the website sucks at getting this across. JS on the other hand is an imperative programming language. If you say "use JS" you may as well say "use Python", the 2 are equivalent in this context and neither are in the same cla…
We tried jsonnet for several months to generate config, but eventually abandoned it because the templates got too hairy. Plus rendering is slow. We ended making the effort to simplify config of all our app’s components to just read from one large yaml file. Far happier with this solution.
It was discussed on HN though I don't have the link handy.
But sure, if you are okay with a single yaml file, that's certainly simpler.
Re: Jsonnet – A data templating language
#74Earlier quoted context omitted.
JS is a lot closer to Scheme and Lisps than an imperative language. In fact, it used to have a lispy syntax before Brenden Eich was forced to change it to make it more approachable.
It's not. http://journal.stuffwithstuff.com/2013/07/18/javascript-isnt...
Re: Jsonnet – A data templating language
#75Earlier quoted context omitted.
What is it about "curly braces as primary delimiters" that you think is a hassle? What would you suggest instead?
It is easy to get confused whether a brace is part of the json or part of the mustache/handlebars/etc. { "hello": {"{{place}}":{{{#items}}"{{thing}}":{{n}},{{/items}}}}, "urls": [{{#items}}"{{url}}",{{/items}}] } It's unambigious and can be reasoned through, but it's certainly hard to tell what structure the template is building at a glance. This is not a complex or contrived example. Syntax highlighting, linters, pr…
If I had to do it all over again I'd probably use the config option and change them to something like '(.', '.)' that doesn't naturally occur in the output language.
Re: Jsonnet – A data templating language
#76Re: Jsonnet – A data templating language
#77Re: Jsonnet – A data templating language
#78Re: Jsonnet – A data templating language
#79All the people suggesting to use JS instead of Jsonnet are completely missing the point. Jsonnet is a functional lazy evaluated language that supports powerful referential concepts. Unfortunately the website sucks at getting this across. JS on the other hand is an imperative programming language. If you say "use JS" you may as well say "use Python", the 2 are equivalent in this context and neither are in the same cla…
In this case, JavaScript's syntax is very similar to Jsonnet. Or at least what is shown in the example can be accomplished in a very similar way. (maybe except anchors, which can be replaced by variables)