GeoJSON serialiser that doesn't explode your nested coordinate arrays
✓ Published0🌍 Public
Aalpha-beta-soup
Last edited Jul 5, 2019
Created on Jul 5, 2019
This example demonstrates a custom GeoJSON serializer that keeps deeply nested coordinate arrays on a single line, avoiding the visual explosion caused by standard pretty-printing. It shows a MultiPolygon feature from RFC7946, with its `geometry.coordinates` array compactly formatted while other properties retain normal indentation. The code uses `JSON.stringify` with a custom `replacer` function that stringifies coordinate arrays, followed by a `replacerWrapper` that removes surrounding quotes. The output is identical to standard formatting except for the coordinates, making GeoJSON files more readable without sacrificing structure.
AI-generated description