Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JsonConverter attribute usage #15

Open
WorldMaker opened this issue Jun 22, 2018 · 1 comment
Open

JsonConverter attribute usage #15

WorldMaker opened this issue Jun 22, 2018 · 1 comment

Comments

@WorldMaker
Copy link

It would be useful if this project included a JSON.NET JsonConverter at the top level that could just be used with a [JsonConverter()] attribute: https://www.newtonsoft.com/json/help/html/JsonConverterAttributeClass.htm

Ideally, I should be able to just adjust my EF model or DTO to my EF model, and wherever JSON serialization happens (such as automatically by WebAPI) it will convert to GeoJSON:

[JsonConverter(typeof(DbGeometryGeoJsonConverter))]
public DbGeometry Geometry { get; set; }

I don't see an example like this in the documentation and searching the source code there doesn't appear to be a class that can be directly used as a JsonConverter in this way. Let me know if I just missed it.

@alatas
Copy link
Owner

alatas commented Feb 24, 2019

@WorldMaker The code uses a similar method, but it constructs the geometry as a composite structure first, then serialize it to a json. DbGeometry consists of defined well-known features but geojson has a hierarchical structure.

But, it seems quite doable in the way that you mentioned. But there may be some changes needed in the usage. I'll take in the consideration for v3 implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants