siwi-json
v1.0.2
Published
# 安装
Downloads
4
Readme
Siwi Json
安装
yarn add siwi-json
npm install siwi-json
v1.0 新增
- 获取单个json json文件内容
- 获取文件夹下json文件内容 非json文件跳过 文件名为key 文件内容为value
/**
* @author [siwi]
* @email [[email protected]]
* @create date 2017-08-19 03:17:57
* @modify date 2017-08-19 03:17:57
* @desc [siwi-json 测试]
*/
const Loadjson = require('siwi-json')
const path = require('path')
class Test {
constructor() {
this.getDirJson()
this.getJson()
}
getDirJson() {
console.log('测试获取文件夹内json文件内容')
let self = this
let dir = path.join(__dirname, 'json')
let content = Loadjson.getDirJson(dir)
console.log(content)
for (let key in content) {
console.log(`${key}:`, `${content[key]}`)
}
}
getJson() {
console.log('测试获取单个json文件内容')
let self = this
let json = path.join(__dirname, 'json', 'test.json')
let content = Loadjson.getJson(json)
console.log(content)
for (let key in content) {
console.log(`${key}:`, `${content[key]}`)
}
}
}
module.exports = new Test()