-
Notifications
You must be signed in to change notification settings - Fork 1
/
jsonObj.js
35 lines (33 loc) · 1.1 KB
/
jsonObj.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
const fs = require('fs');
const path = require('path');
module.exports = {
getJsonObj: function (itemName) {
return getJson(getPath(itemName))
},
getJsonObjRaw: function (itemName) {
return getJson(getPathRaw(itemName))
},
getItem: function (itemName){
return getItemLocal(itemName)
}
};
function getPath(configName) {
let rawdata = fs.readFileSync(path.resolve(__dirname + "/apiMethods/data.json"));
let config = JSON.parse(rawdata);
return (config['jsonPath'] + config[configName] + '.json')
}
function getJson(pathName) {
let rawdata = fs.readFileSync(path.resolve(__dirname, pathName));
let jsonObj = JSON.parse(rawdata);
return (jsonObj)
}
function getPathRaw(configName) {
let rawdata = fs.readFileSync(path.resolve(__dirname + "/apiMethods/data.json"));
let config = JSON.parse(rawdata);
return (config['jsonPath'] + configName + '.json')
}
function getItemLocal(configName){
let rawdata = fs.readFileSync(path.resolve(__dirname + "/apiMethods/data.json"));
let config = JSON.parse(rawdata);
return (config[configName])
}