UNPKG

@loaders.gl/json

Version:

Framework-independent loader for JSON and streaming JSON formats

21 lines 739 B
// loaders.gl // SPDX-License-Identifier: MIT // Copyright (c) vis.gl contributors // Copyright 2022 Foursquare Labs, Inc. import { makeRowIterator } from '@loaders.gl/schema-utils'; /** * Encode a table as a JSON string */ export function encodeTableAsJSON(table, options) { const shape = options?.json?.shape || 'object-row-table'; const strings = []; const rowIterator = makeRowIterator(table, shape); for (const row of rowIterator) { // Round elements etc // processRow(wrappedRow, table.schema); // const wrappedRow = options.wrapper ? options.wrapper(row) : row; strings.push(JSON.stringify(row)); } return `[${strings.join(',')}]`; } //# sourceMappingURL=json-encoder.js.map