Hey guys! I want to develop a system where is pos...
# server
t
Hey guys! I want to develop a system where is possible to “translate” a JSON in another via a web interface. The point of this is give users ability to create those parsers without the programming language. Today I already have this written in NodeJS and using Handlebars (HTML template engine for building JSON sucks 🤮). I’m rewriting some microservices in Kotlin (with #spring) and I’d like your opinion about this system be written in Kotlin? Any suggestion how could I do this?
j
It depends what kinds of features you want to include really. One similar system is XSLT, where you define a bunch of template matchers and the action to apply if that template is the best match. Then you attempt to match the root of the XML structure. From there you explicitly state which nodes you want to continue matching on. You then build up an output XML structure. I guess you could do similar for JSON, but maybe that's catering for more complexity than you want. You might want to consider early whether you want to support streaming to help people out when processing very big JSON documents or whether that is out of scope.
t
The matching for our kind of JSON is very simple. Also we won’t be processing big JSONs, but thank you for the advice. So basically I have the ” base JSON ” and given that I already know which template to use, I want this template to access
key
and
values
from base JSON and also be able to modify something, like applying some functions to the “values”, like uppercasing, getting first 10 from a list, etc
r
You can probably write this in Kotlin/JS, accessing the JSON fields using dynamic types (just like in nodejs).
This way it could be done without any other backend.