0.0.1 • Published 6 years ago

json-convert v0.0.1

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

json-convert

Travis Github All Releases

Convert json to json you want

How to use

install

npm install json-convert --save

convert json

var jsonConver = require('json-conver');
var dataFromAjax = {
    title: 2,
    article: {
        time: 'xxx',
        author: 'x'
    }
};
var convertRule = {
    'title': 'subTitle',
    'article.time': 'time',
    'article.author': 'author'
};



var result = jsonConvert(dataFromAjax, convertRule);
/*
 * the json is converted to:
 * {
 *   title: 2,
 *   time: 'xxx',
 *   author: 'x'
 * }
 */

API

jsonConver(json, rule)

  • json a json you want to convert.
  • rule a convert rule