@aaroca/dson 中文文档教程
dson
读取允许评论的 json 文件
{
/**
* Name of the person
*/
"name": "alvaro",
/**
* Age of the person
*/
"age": 28,
/**
* Pets of the person
*/
"pet": {
/** Pet name */
"name": "batman",
/** Pet age */
"age": 1
}
}
usage
只需添加 npm packge
npm install --save @aaroca/dson
像往常一样添加到您的 js 文件并调用 load 方法
var dson = require('@aaroca/dson');
var dummy = dson.load('./commentedDummy.json');
您将在 dummy
var 上获取 json 文件的内容而不带评论。
{ name: 'alvaro', age: 28, pet: { name: 'batman', age: 1 } }
dson
Read json files allowing comments on it
{
/**
* Name of the person
*/
"name": "alvaro",
/**
* Age of the person
*/
"age": 28,
/**
* Pets of the person
*/
"pet": {
/** Pet name */
"name": "batman",
/** Pet age */
"age": 1
}
}
usage
Just add the npm packge
npm install --save @aaroca/dson
Add to your js file as usual and call the load method
var dson = require('@aaroca/dson');
var dummy = dson.load('./commentedDummy.json');
You will get on dummy
var the content of the json file without comments.
{ name: 'alvaro', age: 28, pet: { name: 'batman', age: 1 } }