@loaders.gl/json
Version:
Framework-independent loader for JSON and streaming JSON formats
39 lines (38 loc) • 1.25 kB
JavaScript
// loaders.gl
// SPDX-License-Identifier: MIT
// Copyright (c) vis.gl contributors
import { parseNDJSONSync } from "./lib/parsers/parse-ndjson.js";
import { parseNDJSONInBatches } from "./lib/parsers/parse-ndjson-in-batches.js";
// __VERSION__ is injected by babel-plugin-version-inline
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
const VERSION = typeof "4.3.2" !== 'undefined' ? "4.3.2" : 'latest';
/** NDGeoJSONLoader */
export const NDJSONLoader = {
dataType: null,
batchType: null,
name: 'NDJSON',
id: 'ndjson',
module: 'json',
version: VERSION,
extensions: ['ndjson', 'ndgeojson'],
mimeTypes: [
'application/geo+x-ndjson',
'application/geo+x-ldjson',
'application/jsonlines', // https://docs.aws.amazon.com/sagemaker/latest/dg/cdf-inference.html#cm-batch
'application/geo+json-seq',
'application/x-ndjson'
],
category: 'table',
text: true,
parse: async (arrayBuffer) => parseNDJSONSync(new TextDecoder().decode(arrayBuffer)),
parseTextSync: parseNDJSONSync,
parseInBatches: parseNDJSONInBatches,
options: {
geojson: {
shape: 'object-row-table'
},
gis: {
format: 'geojson'
}
}
};