object-shape-tester - v6.9.2
    Preparing search index...

    Function parseJsonWithShape

    • 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).

      Type Parameters

      • const CurrentShape extends Shape

      Parameters

      Returns CurrentShape["runtimeType"]

      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.