3 ms·
I think avoiding a parser by using JSON is kind of neat, but it really isn't that difficult to write a parser for a small expression language and you get the be
by spankalee 5y ago
I think avoiding a parser by using JSON is kind of neat, but it really isn't that difficult to write a parser for a small expression language and you get the benefit that you can expose a much nicer syntax to end users with the same parser - rather than having an standard AST and need a parser anyway to have decent UX.
I work on and off on a very simple syntax language for things like templates, but would be well suited towards business rules and such too. It was the first parser I wrote outside of school and pretty easy to understand, small and fast too: https://www.npmjs.com/package/jexpr https://www.npmjs.com/package/jexpr
- ivan888 5y agoProbably the biggest benefit of using something like JSON is the fact that you can safely and easily generate dynamic code without having to worry about different quirks of the particular grammar