-
Notifications
You must be signed in to change notification settings - Fork 13
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
[feature request] add possiblility to filter/modify object structure on serializing and deserializing #6
Comments
Hi TMaddox, Could you please provide detailed examples of the different ways you would like to serialize the same object? Newtonsoft json contracts have many options and I'm not sure which one you would like to see implemented |
Sorry for the unclear OP, I'll try to find a small and accurate example Basically I want to choose at runtime, wether a property or field should be serialized or not. Consider the following classes:
Now I want to do this:
|
Syntax for your example: public class Tree
{
public string Name { get; set; }
public int Age { get; set; }
public Tree() { }
....
}
public void MyMethod()
{
CborOptions options = new CborOptions();
options.Registry.ObjectMappingRegistry.Register<Tree>(objectMapping =>
objectMapping
.AutoMap()
.ClearMemberMappings()
.MapMember(o => o.Name)
);
var serialized = Cbor.Serialize(new Tree("myTree", 10), options);
} |
Thank you very much for implementing all my featue requests! I really appriciate it! |
You're welcome! |
I have to serialize the same object in different ways, with JSON (Newtonsoft.Json library) this is possible with a custom contract, which can be added to the serializer (Reference: https://www.newtonsoft.com/json/help/html/CustomContractResolver.htm)
Do you plan on adding something like this?
The text was updated successfully, but these errors were encountered: