Skip to content

Latest commit

 

History

History
35 lines (24 loc) · 609 Bytes

README.md

File metadata and controls

35 lines (24 loc) · 609 Bytes

object-path-mapper

Javascript Object Mapper via path

var pathMapper = require('object-path-mapper');

var json = {
      key: '653178653',
      first_name: 'Mark',
      last_name: 'Oliver',
      age: 30,
      children: [{
        name: 'Lucy'
      }, {
        name: 'George'
      }]
    };

var map = {
      "key": function (v) { return ('mapped-' + k); },
      "children.[].name": function (v) { return 'name ' + v }
    }


var dest = pathMapper(json, map);

// dest.key = 'mapped-653178653'
// dest.children[0].name = 'name Lucy'
// dest.children[1].name = 'name George'