Skip to content
object-map-transformer (object <-> map)
JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
test
.gitignore
README.md
index.js
package.json

README.md

Object-Map-Transformer

Usage

npm install object-map-transformer --save

Transform object to map

import transformer from 'object-map-transformer';

const object = {
    "name": "cat",
    "age": 3,
    "tags": ["animal", "little"],
    "action": {
        "canJump": true,
        "canFly": false
    }
}

const map = transformer.transformObjectToMap(object);

console.log(map); //{"name": "cat", "age": 3, "tags[0]": "animal", "tags[1]": "little", "action.canJump": true, "action.canFly": false}

Transform map to object

import transformer from 'object-map-transformer';

const map = {
    "name": "cat",
    "age": 3,
    "tags[0]": "animal",
    "tags[1]": "little",
    "action.canJump": true,
    "action.canFly": false
}

const object = transformer.transformMapToObject(map);

console.log(object); //{"name": "cat", "age": 3, tags: ["animal", "little"], "action": {"canJump": true, "canFly": false}}
You can’t perform that action at this time.