Advertisement

采用IContractResolver接口进行序列化处理,并遵循camelCase命名法对属性进行命名 采用IContractResolver接口进行序列化处理,并遵循camelCase命名法对属性进行命名

阅读量:

首先构建一个Address对象,其属性名称的首字母需设置为大写形式

复制代码
 using System;

    
 using System.Collections.Generic;
    
 using System.Linq;
    
 using System.Text;
    
  
    
 namespace JSONDemo
    
 {
    
     public class Address
    
     {
    
     public string Province { get; set; }
    
     public string City { get; set; }
    
     public string County { get; set; }
    
  
    
     public string DetailAddress
    
     {
    
        get{ return County + " " + City + " " + Province; }            
    
     }
    
     }
    
 }
    
    
    
    

2.以下分别展示了未采用以及采用IContractResolver进行序列化的两种情形

全部评论 (0)

还没有任何评论哟~