Skip to content

Instantly share code, notes, and snippets.

@mitchallen
Last active December 30, 2021 14:14
Show Gist options
  • Select an option

  • Save mitchallen/25c98b491cfa0e756e1db5403d9b762d to your computer and use it in GitHub Desktop.

Select an option

Save mitchallen/25c98b491cfa0e756e1db5403d9b762d to your computer and use it in GitHub Desktop.
JSON parser main function example
// 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