jsonpath-lz-transformer

0.0.5 • Public • Published

jsonpath-transformer

This library allow you to transform an object with a jsonpath object definition. It is derivated from: .. that seems to not be maintained anymore. It was migrated to typescript in the process.

Install

yarn add jsonpath-transformer

Examples

import { Transformer } from "jsonpath-transformer";

// Source Object
let source = {
    level1: {
    sublevel1: {
        sublevel2: {
        attr1: "Attr_1",
        },
        array: [{ name: "Yop" }, { name: "Plop" }, { name: "Yop2" }],
    },
    },
}
// Mapper
let mapper = {
    attr1: "$.level1.sublevel1.sublevel2.attr1",
    array: ["$.level1.sublevel1.array", { test: "$.name" }],
}
// Result
let result = Transformer(source, mapper);

result === {
    attr1: "Attr_1",
    array: [{ test: "Yop" }, { test: "Plop" }, { test: "Yop2" }],
}

Readme

Keywords

none

Package Sidebar

Install

npm i jsonpath-lz-transformer

Weekly Downloads

5

Version

0.0.5

License

MIT

Unpacked Size

2.79 kB

Total Files

3

Last publish

Collaborators

  • loopingz