Skip to main content

JSONLoader

The documents JSONLoader parses one ordinary JSON document into its JavaScript value. Objects, arrays, strings, numbers, booleans, and null remain those values. It does not extract rows, infer schemas, create Arrow tables, or stream batches.

import {parse} from '@loaders.gl/core';
import {JSONLoader} from '@loaders.gl/documents/json';

const value = await parse('{"settings":{"enabled":true}}', JSONLoader);

The root loader is metadata-only. Async APIs preload the native parser automatically. For sync use:

import {parseSync} from '@loaders.gl/core';
import {JSONLoaderWithParser} from '@loaders.gl/documents/json';

const value = parseSync('[1,2,3]', JSONLoaderWithParser);
PropertyValue
Extensions.json
MIME typeapplication/json
InputText or UTF-8 bytes; a leading BOM is accepted
OutputAny JSON value (unknown in TypeScript)
ParserNative JSON.parse, without third-party dependencies
OptionsNo document-specific options
Workers / streamingNone

Invalid JSON throws a SyntaxError. Objects containing prototype-shaped keys retain normal JSON.parse behavior; the loader does not assign those keys onto another object.

For JSON paths, streaming arrays, or row-table output, use the JSON loaders in @loaders.gl/tables/json. The minimal core JSON loader remains independent; core does not depend on documents or tables.