UNPKG

@loaders.gl/loader-utils

Version:

Framework-independent loaders for 3D graphics formats

13 lines (12 loc) 368 B
import { getFirstCharacters } from "../binary-utils/get-first-characters.js"; /** * Minimal JSON parser that throws more meaningful error messages */ export function parseJSON(string) { try { return JSON.parse(string); } catch (_) { throw new Error(`Failed to parse JSON from data starting with "${getFirstCharacters(string)}"`); } }