json-convert
v0.0.1
Published
Convert json to json you want
Downloads
33
Maintainers
Readme
json-convert
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