Advertisement

JSON继承和重写了类属性

阅读量:

首先需要定义一个JSON类,该类需继承自JsonConverter,并将类中的属性重新映射至JSON格式中。

复制代码
 using System;

    
 using System.Collections.Generic;
    
 using System.Linq;
    
 using System.Text;
    
 using GongHuiNewtonsoft.Json;
    
 using GongHuiNewtonsoft.Json.Linq;
    
  
    
 namespace JSONDemo
    
 {
    
     public class CustomConverter : JsonConverter
    
     {
    
     private readonly Type[] _types;
    
  
    
     public CustomConverter(params Type[] types)
    
     {
    
         this._types = types;
    
     }
    
  
    
     public override void WriteJson(JsonWriter writer, object value, Json

全部评论 (0)

还没有任何评论哟~