Last active
December 30, 2021 14:14
-
-
Save mitchallen/25c98b491cfa0e756e1db5403d9b762d to your computer and use it in GitHub Desktop.
JSON parser main function example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Author: Mitch Allen | |
| // File: index.js | |
| import { parser } from './parser.js'; | |
| function main() { | |
| let args = process.argv.slice(2); | |
| if (args.length < 2) { | |
| console.log('USAGE: node index.js test-files/good.json test-files/schema.json'); | |
| return; | |
| } | |
| let [inputFile, schemaFile] = args; | |
| console.log(`input file: ${inputFile}`); | |
| console.log(`schema file: ${schemaFile}`); | |
| let json = parser( inputFile, schemaFile ); | |
| if( !json ) { | |
| console.error(`[ERROR] input not valid!`); | |
| return; | |
| } | |
| console.log(JSON.stringify(json,null,2)) | |
| } | |
| main(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment