json-convert

0.0.1 • Public • Published

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

/json-convert/

    Package Sidebar

    Install

    npm i json-convert

    Weekly Downloads

    7

    Version

    0.0.1

    License

    MIT

    Last publish

    Collaborators

    • lyc923