I'm trying to parse GeoJSON geometry definition using System.Text.Json's Utf8JsonReader.
My problem is that the coordinates property of the geometry definition might be positioned prior to the definition of the type. coordinates can be
- a plain array of doubles (
[0, 1]) for geometries of typePoint, - an array of arrays of doubles (
[[0,1],[2,3]]) for geometries of typeLineString - an array of arrays of arrays of doubles (
[[[0,0],[10,0],[10,10],[0,0]],[[1,1],[9,9],[1,9],[1,1]]]) for geometries of typePolygonwith holes and even - an array of the above for geometries of type
MultiPolygon.
Thus I am not be able to parse the coordinates property properly if I don't know the type.
Is there a way to read it as whole and parse it later using Utf8JsonReader?