durian
Make your json support comment
only support single line comment '//'
Usage
parse
const fs = ;const durian = ; const input = fs;const result = durian; // same as JSON.parse, just remove comments before parse;
input.json
// head comment "code": 200 "message": "success" "result": "list": "goodsId": 1 "goodsName": "Nike Kobe 8" "url": "https://www.kaola.com" // { // "goodsId": 2, // "goodsName": "Nike Kobe 9", // "url": "https://www.kaola.com" // }, "goodsId": 3 "goodsName": "Nike Kobe 10" "url": "https://www.kaola.com" "total": 100 // tail comment
And the result is(a javascript variable, not string):
"code": 200 "message": "success" "result": "list": "goodsId": 1 "goodsName": "Nike Kobe 8" "url": "https://www.kaola.com" "goodsId": 3 "goodsName": "Nike Kobe 10" "url": "https://www.kaola.com" "total": 100
minify
const fs = ;const durian = ; const input = fs;const result = durian;
And the result is(a string, remove the whitespaces within input):
"code": 200"message": "success""result": "list": "goodsId": 1"goodsName": "Nike Kobe 8""url": "https://www.kaola.com""goodsId": 3"goodsName": "Nike Kobe 10""url": "https://www.kaola.com""total": 100
Build
$ npm run build
Publish
$ npm run publish