Utils

The static GeoJsonUtils utilities class lets you do a bunch of different stuff in relation to GeoJSON.

Parsing

The GeoJsonUtils.Parse methods lets you parse a raw JSON string into the corresponding GeoJsonObject.

If you have a JSON string with a feature or geometry, you can use the method like:

// Parse the JSON
GeoJsonObject obj = GeoJsonUtils.Parse("{\"type\":\"Point\",\"coordinates\":[9.536067,55.708116]}");

In this example, we can see that the JSON string represents a Point, so the result will be an instance of GeoJsonPoint (which is a subclass of GeoJsonObject).

An overload lets you specify the return type via a generic type parameter:

// Parse the JSON
GeoJsonPoint obj = GeoJsonUtils.Parse<GeoJsonPoint>("{\"type\":\"Point\",\"coordinates\":[9.536067,55.708116]}");

Loading

Where the GeoJsonUtils.Parse methods can be used for parsing a raw JSON string that you already have in memory, you can use the similar GeoJsonUtils.Load methods to load a JSON file from disk:

// Parse the JSON
GeoJsonObject obj = GeoJsonUtils.Parse("C:/MyGeoJsonPoint.json");

And again with a generic type parameter:

// Parse the JSON
GeoJsonPoint obj = GeoJsonUtils.Load<GeoJsonPoint>("C:/MyGeoJsonPoint.json");