Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/miaowing/object-map-transformer
object-map-transformer (object <-> map)
https://github.com/miaowing/object-map-transformer
map-to-object object-to-map transformer
Last synced: 3 days ago
JSON representation
object-map-transformer (object <-> map)
- Host: GitHub
- URL: https://github.com/miaowing/object-map-transformer
- Owner: miaowing
- Created: 2017-07-20T12:00:29.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-07-20T13:26:54.000Z (over 7 years ago)
- Last Synced: 2024-11-02T20:33:46.869Z (12 days ago)
- Topics: map-to-object, object-to-map, transformer
- Language: JavaScript
- Homepage:
- Size: 1.95 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Object-Map-Transformer
## Usage
```
npm install object-map-transformer --save
```### Transform object to map
``` javascript
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
``` javascript
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}}
```