Read and parse a JSON file and verify its contents against the given shape definition. Also handles top level empty strings and 'undefined' (both are converted to undefined).
'undefined'
undefined
This will only work when run in a server / Node.js environment.
Optional
import {readJsonWithShape, defineShape} from 'object-shape-tester';const result = readJsonWithShape('./my-file.json', defineShape({a: ''})); Copy
import {readJsonWithShape, defineShape} from 'object-shape-tester';const result = readJsonWithShape('./my-file.json', defineShape({a: ''}));
If the parsed JSON does not match the shape definition or if the JSON parsing throws an error.
Read and parse a JSON file and verify its contents against the given shape definition. Also handles top level empty strings and
'undefined'(both are converted toundefined).This will only work when run in a server / Node.js environment.