Skip to content

KitRefresh/jutils-schema-mapping

Repository files navigation

JSON Utils - Schema Mapping

A JSON oriented package to transfrom a schema to another schema.

Installation

npm install --save jutils-schema-mapping

or

yarn add jutils-schema-mapping

Usage

  1. Basic usage
const { convert } = require('jutils-schema-mapping');

let output = convert(
  { name: "myName" },
  [                       // A series of mapping rules.
    {
      name: "__root__",   // Default entry rule name.
      rules: [
        ["$.name", "string.uppercase", "T.user.name"]
      ]
    }
  ]
)

/**
 * output = {
 *  user: {
 *    name: "MYNAME" 
 *  }
 * }
 */
  1. More examples

    Please see those examples under the 'examples/' folder.

Mapping rule schema

export class StringStyledMappingRule {
  name: string;
  rules: Rule[];
}

Pipe schema

  1. Pull data

    Powered by json-path

  2. Transform data

    string.uppercase, object.get('name')

  3. Push data

    T.name, T.person.name

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published