Advertisement

JSON使用oxide,ErrorHandling,DefaultValue属性

阅读量:

一、使用JsonIgnoreAttribute忽略其属性序列化

1.构建一个Movie类的实例,并在该实例的相应属性上设置JsonIgnore注解。

复制代码
 using System;

    
 using System.Collections.Generic;
    
 using System.Linq;
    
 using System.Text;
    
 using GongHuiNewtonsoft.Json;
    
  
    
 namespace JSONDemo
    
 {    
    
     public class Movie
    
     {
    
     public string Name { get; set; }
    
  
    
     public string Director { get; set; }
    
  
    
     [JsonIgnore]
    
     public DateTime? LaunchDate { get; set; }
    
     }
    
 }
    
    
    
    
  1. 创建Movie类的实例对象,并为其未被关注的属性进行赋值操作。
复制代码
 using System;

全部评论 (0)

还没有任何评论哟~