Blueprint for data structure:
public class Movie
{
public string Name { get; set; }
}
Using Newtonsoft.Json, I have the following configuration for Json serialization.
var settings = new JsonSerializerSettings() {
ContractResolver = new CamelCasePropertyNamesContractResolver(),
};
Clearly that, this will print out:
{
name: null
}
Now, I need to add another NullToEmptyStringResolver to the ContractResolver in JsonSerializerSettings, how can I achieve that which output as below:
{
name: ""
}
- Please note that my NullToEmptyStringResolver is already written. But I need to add both NullToEmptyStringResolver and CamelCasePropertyNamesContractResolver to the Contract Resolver.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…