Skip to main content

Overview

The @loaders.gl/json module parses JSON. It can parse arbitrary JSON data but is optimized for:

  • loading tabular data stored in JSON arrays.
  • loading tabular geospatial data stored in GeoJSON.
  • loading tabular data from various streaming JSON and GeoJSON formats, such as new-line delimited JSON.

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.

Installation

npm install @loaders.gl/core @loaders.gl/json

Loaders and Writers

Exports
JSONLoader
NDJSONLoader
GeoJSONLoader
NDGeoJSONLoader
JSONWriter
GeoJSONWriter

Additional APIs

JSON Format Notes

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 |