Parse a JSON string and verify it against the given shape definition. Also handles top level empty strings and 'undefined' (both are converted to undefined).
'undefined'
undefined
Optional
import {parseJsonWithShape, defineShape} from 'object-shape-tester';const result = parseJsonWithShape('{"a": "hello"}', defineShape({a: ''})); Copy
import {parseJsonWithShape, defineShape} from 'object-shape-tester';const result = parseJsonWithShape('{"a": "hello"}', defineShape({a: ''}));
If the parsed JSON does not match the shape definition or if the JSON parsing throws an error.
Parse a JSON string and verify it against the given shape definition. Also handles top level empty strings and
'undefined'
(both are converted toundefined
).