GeoJSON.Net is a .NET library for the RFC 7946 The GeoJSON Format and it uses and provides Newtonsoft Json.NET converters for serialization and deserialization of GeoJSON data.
GeoJSON.Net NuGet package:
Install-Package GeoJSON.Net
Position position = new Position(51.899523, -2.124156);
Point point = new Point(position);
string json = JsonConvert.SerializeObject(point);
string json = "{\"coordinates\":[-2.124156,51.899523],\"type\":\"Point\"}";
Point point = JsonConvert.DeserializeObject<Point>(json);
See the Tests for more examples.
System.Text.Json is the default (recommended) serializer. GeoJSON.Net does not play well with System.Text.Json and only supports Newtonsoft.Json
GeoJSON.Text is a fork of this repository and have been developed to support System.Text.Json.
If you still need to use Newtonsoft.Json in ASP.Net Core 3.1+, you must overwrite the default serializer.
- add the "Microsoft.AspNetCore.Mvc.NewtonsoftJson" NuGet Package
- add "services.AddControllers().AddNewtonsoftJson();" to your service configuration.
Highly welcome! Just fork away and send a pull request. We try and review most pull requests within a couple of days. There is now a version 2.0.0 branch. I've created this ready for any breaking changes and any extra features and would encourage anything that isn't a bug fix to go in there.
This library would be NOTHING without its contributors - thanks so much!!
This project exists thanks to all the people who contribute.
Thank you to all our backers! 🙏 [Become a backer]
Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor]