question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NEST 6.0 GA: JsonProperty attribute support, Rename gone?

See original GitHub issue

We have some DTOs that we’ve previously been able to share among our middle tier C# models and the models we use for ES. I’ve seen ES 5.x documentation which shows that JsonProperty is allowed but w/ the internalization of Newtonsoft (or whatever parser you’ve chosen), I’ve discovered that I have to use Rename or Text on all my models which would be fine except where I want directly share them as I explained above. Should JsonProperty still be supported as before in NEST 6.0? I just discovered this because, for some of our indexes, we use strict mappings. Anyway, the DTOs are in a place where I’d prefer not to expose the Nest library.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
Mpdreamzcommented, Feb 6, 2018

@jonyadamit yes that is correct.

1reaction
guruprasad83commented, Nov 13, 2019

You won’t be able to use JsonPropertyAttribute @tdoman, since it is a Json.NET type and the NEST assembly will not know what this is; the internalized Json.NET is re-namespaced from Newtonsoft.Json to Nest.Json, so the attribute that NEST knows about is Nest.Json.JsonPropertyAttribute and its internal.

PropertyNameAttribute exposes a hook to use to control the serialized property names of your types within NEST 6.x, similar to how you would have used JsonPropertyAttribute in NEST 5.x. We could have considered making Nest.Json.JsonPropertyAttribute a public type, but I think this is perhaps more confusing, especially if you’re using NEST in a project alongside Json.NET!

The PropertyNameAttribute helped a lot for me. Thanks @russcam

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I rename sub-properties of ...
I have implemented that stuff for first-level object properties when serializing using custom ContractResolver like here:
Read more >
Elasticsearch.Net and NEST - Breaking changes
This lists all the binary breaking changes in NEST from 5.x (last commit in 5.x at time of 6.0.0 GA release) to 6.x...
Read more >
JsonPropertyAttribute name
JsonPropertyAttribute name. This sample uses JsonPropertyAttribute to change the names of properties when they are serialized to JSON.
Read more >
Cumulative Changes from Net Express to ...
This provides edit, compile and debug support for Visual COBOL and Enterprise Developer users in Visual Studio Code. Note: The new Micro Focus ......
Read more >
Cumulative Changes from Server Express to ...
The version of Visual COBOL in which the change was introduced,. • A link to more information. ... addition of the JSON property...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found