jutils-schema-mapping

0.1.4 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i jutils-schema-mapping

Weekly Downloads

0

Version

0.1.4

License

MIT

Unpacked Size

116 kB

Total Files

75

Last publish

Collaborators

  • yeze322