The @loaders.gl/json
module parses JSON. It can parse arbitrary JSON data but is optimized for:
The JSON loaders also support batched parsing which can be useful when loading very large tabular JSON files to avoid blocking for tens of seconds.
npm install @loaders.gl/core @loaders.gl/json
Loader |
---|
JSONLoader |
NDJSONLoader |
GeoJSONLoader |
NDGeoJSONLoader |
The classic JSON format was designed for simplicity and is supported by standard libraries in many programming languages.
Several JSON Streaming Formats (Wikipedia) have emerged, that typically
place one JSON object on each line of a file. These are convenient to use when streaming data and are
supported by via the NDJSONLoader
and NDGeoJSONLoader
.
At the moment, auto-detection between streaming and classic JSON based on file contents is not implemented, so two separate loaders are provided. The two loaders look for different file extensions or MIME types as specified in the table below, allowing correct distinctions to be made in usage.
Format | Extension | MIME Media Type | Support | |
---|---|---|---|---|
JSON | .json | application/json | JSONLoader | |
NewLine Delimited JSON | .ndjson | application/x-ndjson | NDJSONLoader | |
JSON Lines | .jsonl | application/x-ldjson | NDJSONLoader | |
JSON Text Sequences | application/json-seq | NDJSONLoader . Partial records must not span multiple lines. | ||
GeoJSON | .json | application/geo+json | JSONLoader | |
Newline Delimited GeoJSON | .ndgeojson | NDJSONLoader | ||
GeoJSON Lines | .geojsonl | NDJSONLoader | ||
GeoJSON Text Sequences | application/geo+json-seq | NDJSONLoader |