Reputation: 15797
How can I change the way Newtonsoft JSON.NET serializes property names of objects?
Upvotes: 2
Views: 3811
Reputation: 2617
You can create a model with the property names. And change them by creating some private variables that will be use to as return values for the properties. This is will direct the deserializer to reset the name of the property.
private int _privateId;
public int NameThatExistAlreadyInTheJson
{
set { _privateId = value; }
}
public int NameYouWantItToBeDisplayInstead
{
get { return _privateId; }
}
Upvotes: 2
Reputation: 107498
A couple of ways:
JsonTextWriter
class:
JsonConverter
that does what you want:
Upvotes: 3