@shopify/cli-kit
Version:
A set of utilities, interfaces, and models that are common across all the platform features
18 lines (17 loc) • 560 B
TypeScript
/**
* Safely parse JSON with helpful error messages.
*
* @param jsonString - The JSON string to parse.
* @param context - Optional context about what's being parsed (e.g., file path, "API response").
* @returns The parsed JSON object.
* @throws AbortError if JSON is malformed.
*
* @example
* // Parse with context
* const data = parseJSON(jsonString, '/path/to/config.json')
*
* @example
* // Parse without context
* const data = parseJSON(jsonString)
*/
export declare function parseJSON<T = unknown>(jsonString: string, context?: string): T;