Skip to content

nlighten-oss/json-transform

Repository files navigation

json-transform

Packages

Language Name Description License Status
Java co.nlighten.json-transform Java library for transforming JSON objects Apache License 2.0 Maven Central Version
JavaScript @nlighten/json-transform JSON transformers JavaScript implementation MIT npm
JavaScript @nlighten/json-transform-core Core types and utilities for handling JSON transformers MIT npm

Getting Started

Java

  • In your application initialization code set the JsonTransformerConfiguration with your preferred provider:
	public static void main(String[] args) {
        JsonTransformerConfiguration.set(new GsonJsonTransformerConfiguration());
        // ...
    }
  • See available adapters here

Then in the code where you want to transform JSON objects:

    // 'definition' is a JSON (in your selected provider's structure) 
    // defining the spec of the transformer    
    JsonTransformer transformer = new JsonTransformer(definition);
    // 'input' - The input of the transformer (referred as '$')
    // 'additionalContext' - (optional) Map of additional inputs to refer during transformation 
    Object transformed = transformer.transform(input, additionalContext);

JavaScript

    // 'definition' is the spec of the transformer    
    const transformer = new JsonTransformer(definition);
    // 'input' - The input of the transformer (referred as '$')
    // 'additionalContext' - (optional) Map of additional inputs to refer during transformation 
    const result = await transformer.transform(input, additionalContext);