diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2023-12-19 00:33:38 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-19 05:33:38 +0000 |
commit | 1ced9aafc00c10992bab8bd3f1b6b1397f05b7b9 (patch) | |
tree | 305bb2b3bfc7fc3b051ee1cd3d1c35f442af0de4 /dev/bin | |
parent | 5f96276fda93dcad39f2165fd3c8d890aa5f9be5 (diff) |
Make JSON.parse usage safer (#373)
* Make JSON.parse usage safer
* Fix any type
* Add readResponseJson
* Use readResponseJson
* Additional updates
* Rename files
* Add types
Diffstat (limited to 'dev/bin')
-rw-r--r-- | dev/bin/schema-validate.js | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/dev/bin/schema-validate.js b/dev/bin/schema-validate.js index 206f26ca..bbd5ad5f 100644 --- a/dev/bin/schema-validate.js +++ b/dev/bin/schema-validate.js @@ -18,6 +18,7 @@ import fs from 'fs'; import {performance} from 'perf_hooks'; +import {parseJson} from '../../ext/js/core/json.js'; import {createJsonSchema} from '../schema-validate.js'; /** */ @@ -39,14 +40,14 @@ function main() { } const schemaSource = fs.readFileSync(args[0], {encoding: 'utf8'}); - const schema = JSON.parse(schemaSource); + const schema = parseJson(schemaSource); for (const dataFileName of args.slice(1)) { const start = performance.now(); try { console.log(`Validating ${dataFileName}...`); const dataSource = fs.readFileSync(dataFileName, {encoding: 'utf8'}); - const data = JSON.parse(dataSource); + const data = parseJson(dataSource); createJsonSchema(mode, schema).validate(data); const end = performance.now(); console.log(`No issues detected (${((end - start) / 1000).toFixed(2)}s)`); |