An open API service indexing awesome lists of open source software.

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

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 ) );