-Code reformat
This commit is contained in:
+37
-37
@@ -6,44 +6,44 @@ using System.Text;
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Serializer
|
||||
{
|
||||
public class DefaultValueAttributeIgnore
|
||||
{
|
||||
#region Types
|
||||
public class Customer
|
||||
public class DefaultValueAttributeIgnore
|
||||
{
|
||||
public string FirstName { get; set; }
|
||||
public string LastName { get; set; }
|
||||
|
||||
[DefaultValue(" ")]
|
||||
public string FullName
|
||||
{
|
||||
get { return FirstName + " " + LastName; }
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
public void Example()
|
||||
{
|
||||
#region Usage
|
||||
Customer customer = new Customer();
|
||||
|
||||
string jsonIncludeDefaultValues = JsonConvert.SerializeObject(customer, Formatting.Indented);
|
||||
|
||||
Console.WriteLine(jsonIncludeDefaultValues);
|
||||
// {
|
||||
// "FirstName": null,
|
||||
// "LastName": null,
|
||||
// "FullName": " "
|
||||
// }
|
||||
|
||||
string jsonIgnoreDefaultValues = JsonConvert.SerializeObject(customer, Formatting.Indented, new JsonSerializerSettings
|
||||
#region Types
|
||||
public class Customer
|
||||
{
|
||||
DefaultValueHandling = DefaultValueHandling.Ignore
|
||||
});
|
||||
public string FirstName { get; set; }
|
||||
public string LastName { get; set; }
|
||||
|
||||
Console.WriteLine(jsonIgnoreDefaultValues);
|
||||
// {}
|
||||
#endregion
|
||||
[DefaultValue(" ")]
|
||||
public string FullName
|
||||
{
|
||||
get { return FirstName + " " + LastName; }
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
public void Example()
|
||||
{
|
||||
#region Usage
|
||||
Customer customer = new Customer();
|
||||
|
||||
string jsonIncludeDefaultValues = JsonConvert.SerializeObject(customer, Formatting.Indented);
|
||||
|
||||
Console.WriteLine(jsonIncludeDefaultValues);
|
||||
// {
|
||||
// "FirstName": null,
|
||||
// "LastName": null,
|
||||
// "FullName": " "
|
||||
// }
|
||||
|
||||
string jsonIgnoreDefaultValues = JsonConvert.SerializeObject(customer, Formatting.Indented, new JsonSerializerSettings
|
||||
{
|
||||
DefaultValueHandling = DefaultValueHandling.Ignore
|
||||
});
|
||||
|
||||
Console.WriteLine(jsonIgnoreDefaultValues);
|
||||
// {}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user