@shopify/cli-kit
    Preparing search index...

    Function parseJSON

    • Safely parse JSON with helpful error messages.

      Type Parameters

      • T = unknown

      Parameters

      • jsonString: string

        The JSON string to parse.

      • Optionalcontext: string

        Optional context about what's being parsed (e.g., file path, "API response").

      Returns T

      The parsed JSON object.

      AbortError if JSON is malformed.

      // Parse with context
      const data = parseJSON(jsonString, '/path/to/config.json')
      // Parse without context
      const data = parseJSON(jsonString)