0.1.4 • Published 7 years ago

jutils-schema-mapping v0.1.4

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

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

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago