3 ms·
I think it's a cool proof of concept and you tried out a bunch of ideas that could work, but I don't think you should use this approach for anything. JSON is no
by macspoofing 10y ago
I think it's a cool proof of concept and you tried out a bunch of ideas that could work, but I don't think you should use this approach for anything. JSON is not conducive for encapsulating complex logic, and it shows. Who is going to write and maintain that spaghetti code? Anyway, code execution at the datasource, is not a new problem, and there are approaches to solving it. Redis for example allows you to upload and execute Lua scripts at the source - way easier, way more readable, makes infinitely more sense. So why not use Lua or just use JavaScript - since your front-end code is all JavaScript anyway?
- epoberezkin 10y agoRedis's implementation of Lua is extremely limited, and even then there is no easy way to validate the script apart from sending to the server. JSONScript can be simply validated against the JSON-schema, no execution is required to check it's validity. I see this solution as server-side script processing on top of existing REST API(s), as I wrote below. Using Lua for this purpose is possible I guess; but I want the solution that is easy to implement, extend and maintain. And I am happy to write and maintain this code; whether it's "spaghetti" depends on the way it is written, as for all languages.
- epoberezkin 10y agoMany people use YAML instead of JSON by the way - a bit fewer characters.