A JSON oriented package to transfrom a schema to another schema.
npm install jutils-schema-mappingnpm install --save jutils-schema-mapping
yarn add jutils-schema-mapping
javascript
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"
* }
* }
*/
`
2. More examples
Please see those examples under the 'examples/' folder.
Mapping rule schema
`typescript
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`