UNPKG

staticql

Version:

Type-safe query engine for static content including Markdown, YAML, JSON, and more.

15 lines (14 loc) 465 B
/** * Parses a JSON string or buffer and returns the corresponding object. * * Automatically decodes a Uint8Array using UTF-8 if needed. * * @param rawContent - Raw JSON content as string or binary (Uint8Array). * @returns Parsed JSON object. * @throws If the input is not valid JSON. */ export function parseJSON({ rawContent }) { return JSON.parse(typeof rawContent === "string" ? rawContent : new TextDecoder().decode(rawContent)); }