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.

JsonIgnore to ignore field

See original GitHub issue

During the mapping process, the AutoMap will use the JsonProperty to get the name of the property, but it will not follow a JsonIgnore attribute to ignore the field from the mapping. Currently I am just putting [Object(Ignore = true)] everywhere that I have a JsonIgnore attribute.

E.g. (just a random example)

public string CultureInfoID { get; set; }

[JsonIgnore]
[Object(Ignore = true)]
public CultureInfo CultureInfo
{
        get
        {
                return new CultureInfo(CultureInfoID, false);
        }
}

I am not sure if this is correct. Should it not follow the JsonIgnore attribute and not map the field? Kind of feels inconsistent, or is this the expected behavior?

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
Mpdreamzcommented, Jan 29, 2016

We adhere to [JsonProperty(Name="")] when calling AutoMap() by virtue of PropertyName supporting it. I think the principle of least surprise here is that we also ignore properties marked with JsonIgnore when calling AutoMap() as at index time they will never be indexed anyway.

Will push a fix shortly

0reactions
rwb196884commented, Apr 28, 2019

NEST 6.6.0 and

ConnectionSettings cs = new ConnectionSettings(
  connectionPool: connectionPool,
  sourceSerializer: (builtin, settings) => new JsonNetSerializer(builtin, settings)
);
Read more comments on GitHub >

github_iconTop Results From Across the Web

Ignore fields from Java object dynamically while sending ...
Yes, you can specify which fields are serialized as JSON response and which to ignore. This is what you need to do to...
Read more >
Jackson Ignore Properties on Marshalling
This tutorial will show how to ignore certain fields when serializing an object to JSON using Jackson 2.x.
Read more >
How can we ignore the fields during JSON serialization in ...
If there are fields in Java objects that do not wish to be serialized, we can use the @JsonIgnore annotation in the Jackson...
Read more >
How to ignore properties with System.Text.Json
To ignore individual properties, use the [JsonIgnore] attribute. The following example shows a type to serialize. It also shows the JSON ...
Read more >
Jackson @JsonIgnore, @JsonIgnoreProperties and ...
In this tutorial, I show you how to ignore certain fields when serializing an object to JSON using Jackson @JsonIgnore, @JsonIgnoreProperties and ...
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