The Customer Data Platform for Developers
Website
·
Documentation
·
Community Slack
rudder-json-template-engine
A library to process JSON data using a custom syntax based on javascript and jspath. We thank the jspath authors for their excellent work, as our library is an extension of the original library. We also want to thank IBM team for their work on jsonata, as we have taken several ideas from the library. You can also consider our library as an alternative to jsonata.
Overview
This library generates a javascript function code from the template and then uses the function to evaluate the JSON data. It outputs the javascript code in the following stages:
- Lexing (Tokenization)
- Parsing (AST Creation)
- Translation (Code generation)
Engine class abstracts the above steps and provides a convenient way to use the json templates to evaluate the inputs.
Features
- Variables
- Arrays
- Objects
- Functions
- Bindings
- Comments
- Paths
- Conditions
- Math operations
- Logical operations
- Compile time expressions
For more examples, refer Scenarios
Getting started
npm install rudder-json-template-engine
const engine = new JsonTemplateEngine(`'Hello ' + .name`);
engine.evaluate({name: 'World'});
Testing
npm test
Contribute
We would love to see you contribute to RudderStack. Get more information on how to contribute here.
License
The RudderStack rudder-json-template-engine
is released under the MIT License.