Reputation: 10046
Does JsonIgnore not work when a property has data? I have the followin class:
public class SomeObject
{
public string Name { get; set; }
public DateTime Created { get; set; }
public List<string> ErrorList { get; set; }
[JsonIgnore]
public Dictionary<string, object> Parameters { get; set; }
public SomeObject()
{
this.ErrorList = new List<string>();
this.Parameters = new Dictionary<string, object>();
}
}
My expectation was that JsonIgnore would exclude properties from De- / Serialization. My RavenDB document has data. Am I missing something?
Upvotes: 0
Views: 350
Reputation: 241890
If you are using any of the 1.2 (unstable) builds, you'll need to use the copy of JsonIgnoreAttribute
that's in Raven.Imports.Newtonsoft.Json
. All of Json.Net has been internalized.
The better approach would to not expose your parameters dictionary directly via a property, since you don't want it serialized. Perhaps a pattern like the following would suffice:
private readonly Dictionary<string, object> _parameters = new Dictionary<string, object>();
public Dictionary<string, object> GetParameters()
{
return _parameters;
}
Personally, I try not to bring any external dependency into my domain objects, so I like to avoid things like [JsonIgnore]
anyway.
EDIT
Sorry, I just saw in your title the 960 version. You may be encountering a different issue, which is that 960 relies on Json.Net 4.0.8. You may have better luck with the 972 client at http://nuget.org/packages/RavenDB.Client/1.0.972. Still, I think the better advice is to restructure to avoid needing it at all.
Upvotes: 2