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

Ignore some certain properties when serialized. #86

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Commits on May 22, 2018

  1. Ignore some certain properties when serialized.

    In our project,each fields and properties whose modifier is PUBLIC will be serialized as a string format.Of course,we could modify their modifier to INTERNAL ,even PRIVATE,to prevent to serialize the fields or properties you don't really want.But in some certain situations you must to make a data modified as PUBLIC,we can also use the following changes. 
    I added a custom attribute("NonToJsonAttribute") in project,and use reflection to avoid adding fields or attributes to a serialized collection.By this way,every fields and properties that marked with "NonToJson" attribute will not be serialized.
    Below is the example-code:
    interface ITest
            {
                int TestProperty { get; }
            }
            class Test : ITest
            {
                //The property what I want not to serialize
                [NonToJson]
                public int TestProperty => 0;
                public int Other { get; set; } = 1;
            }
    
            . . .
    
            Test t = new Test();
            string result = LitJson.JsonMapper.ToJson(t);
    BinGuoGuo authored May 22, 2018
    Configuration menu
    Copy the full SHA
    1fc42a5 View commit details
    Browse the repository at this point in the history

Commits on Dec 6, 2018

  1. Configuration menu
    Copy the full SHA
    e560389 View commit details
    Browse the repository at this point in the history