0.5.1 • Published 5 months ago
json-verifier-cli v0.5.1
Options:
-V, --version output the package version number
-f, --file <file_path> verify the JSON file for the file path given
-fd, --folder <folder_path> verify all the JSON files and parse them for the folder path given
-d, --max-depth <number> set the max depth for the JSON file(s) you want to check
-l --logging <Y/N> Choose if you want to log the results of the verification. By default it is enabled.
-h, --help display help for available options
import { verifyJson, verifyJsonFromPath } from 'json-verifier-cli';
/**
* for verifying and parsing a json object string directly from code
*/
const obj = `{"key":"value", "key2":true}`;
const maxDepth : number = 10 // (optional) any integer above 0 (default is 19)
console.log(verifyJson(obj, maxDepth)); //output: {key:"value", list:true}
/**
* absoluteFilePath.json
* {
* "key":123,
* "key2": "value"
* }
*/
const filePath = './absoluteFilePath.json'
const maxDepth : number = 10 // (optional) any integer above 0 (default is 19)
const enableLoggingToFile : boolean = false // (optional) Y, y, N, n (default is Yes or enabled)
/** outputs an object with filename and result (error or parsed JSON data)
* { file: "file1.json", result: <data/error> },
*/
console.log(verifyJsonFromPath(filePath, maxDepth, enableLoggingToFile))
/**
* absoluteFolderPath/
* - file1.json
* - file2.json
* - file3.json ... and so on
*/
const folderPath = './absoluteFolderPath'
/** outputs an array of object with filename and result (error or parsed JSON data)
* [
* { file: "file1.json", result: <data/error> },
* { file: "file2.json", result: <data/error> },
* ]
*/
console.log(verifyJsonFromPath(folderPath, maxDepth, enabledLoggingToFile))
Thanks for using my project and reading till here! Any help is much appreciated!!