Skip to main content

TypeScript

TypeScript/JavaScript library API reference

NameDescriptionLicenseStatus
@nlighten/json-transformJSON transformers JavaScript implementationMITnpm

Usage​

Transformation​

  • Use the JsonTransformer class to transform JSON objects
Notice

The implementation uses async methods and returns a Promise.

const transformer = new JsonTransformer(definition);
const result = await transformer.transform(input);

API​

JsonTransformer​

declare class JsonTransformer {

/**
* Creates a new JSON transformer from definition
*
* @param definition The transformer definition
* @param functionsAdapter (optional) A specific transformer functions adapter (otherwise uses the default)
*/
constructor(
definition: any,
functionsAdapter?: TransformerFunctionsAdapter
);

/**
* Transforms the payload using the transformer definition
*
* @param payload The payload to transform
* @param additionalContext (optional) Additional context to use in the transformation
* @returns A promise to the transformed payload
*/
transform(payload?: any, additionalContext?: Record<string, any>) : Promise<any>;

/**
* Gets the transformer definition
*/
getDefinition() : any;
}