https://github.com/andrewn/hash-mapper-js
Javascript implementation of http://github.com/ismasan/hash_mapper
https://github.com/andrewn/hash-mapper-js
Last synced: over 1 year ago
JSON representation
Javascript implementation of http://github.com/ismasan/hash_mapper
- Host: GitHub
- URL: https://github.com/andrewn/hash-mapper-js
- Owner: andrewn
- Created: 2010-07-26T19:58:29.000Z (almost 16 years ago)
- Default Branch: master
- Last Pushed: 2010-07-26T20:24:51.000Z (almost 16 years ago)
- Last Synced: 2025-01-13T13:31:01.171Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 93.8 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README
Awesome Lists containing this project
README
hash-mapper-js is a javascript implementation of the ruby HashMapper project.
It's useful if you want to transform JSON (or, any javascript datastructure) to another.
e.g.
// Test data
var data = {
"name" : {
"first": "Andrew",
"last" : "Nicolaou"
},
"properties" : {
"type" : "person",
"egg" : "organic"
},
"tagid" : "123",
};
var map = new HashMapper();
map.from( '/name' ) .to( 'tag_attributes/name' );
map.from( '/properties/type' ).to( 'tag_attributes/type' );
map.from( '/tagid' ) .to( 'tag_id' );
map.from( '/properties/egg' ) .to( '/chicken' );
console.dir( map.normalize( data ) );