简体   繁体   中英

Ignore a property from being serialized when trying to serialize an object to Json using JIL (like [JsonIgnore] in newtonsoft)

I've recently changed my Json serialization/deserialization logic from Newtonsoft to JIL ,it(Jil) works with better performance than newtonsoft (as expected) but I have one major problem with it

My model objects are usually big objects with lots of properties including their own props and their parent props, so I can't pass the whole object to the client on every request , I usually exclude some of their properties (unnecessary ones).

In newtonsoft I easily used JsonIgnore attribute and my need was satisfied but as I googled a bit I haven't found it's (JsonIgnore) equivalent attribute in JIL.

Does this attribute exists in JIL or I should write it myself??

if the answer is no how can I write an attribute that Ignores property from being serialized with JIL because I have no access to JIL JSON.Serialize mechanism

any help would be hugely appreciated

我自己找到答案我应该使用JilDirective属性,第一个属性为false,见下文

[JilDirective(true)]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM