Skip to content

How to serialize only some variables of a derived class, and ignore all variables in the base class #906

@yosimba2000

Description

@yosimba2000

Sorry, not sure where to ask for help.

I have two classes, A and B. B inherits from A.

Class A{
public float a;
}
Class B:A{
public float b;
}

I would like to serialize class B and its float b variable, but ignore all serialization of variables inside Class A, and potentially ignoring serialization of Class A altogether if possible.

Newtonsoft.JSON has an OptIn attribute that does exactly this by marking variables with [JsonProperty], but it's not AOT compatible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions