好久没有做web了,JSON目前比较流行,闲得没事,所以动手试试将对象序列化为JSON字符(尽管DotNet Framework已经有现成的库,也有比较好的第三方开源库),而且只是实现了处理简单的类型,并且DateTime处理的也不专业,有兴趣的筒子可以扩展,代码比较简单,反序列化木有实现:( ,直接贴代码吧,都有注释了,所以废话不多说  :)

 

/// <summary>
    
/// Nested class of Person.
    
/// </summary>
    public class House
    {
        
public string Name
        {
            
get;
            
set;
        }
        
public double Price
        {
            
get;
            
set;
        }
    }

    
/// <summary>
    
/// Person dummy class
    
/// </summary>
    public class Person
    {
        
public string Name
        {
            
get;
            
set;
        }
        
public int Age
        {
            
get;
            
set;
        }
        
public string Address
        {
            
get;
            
set;
        }
        
private int h = 12;

        
public bool IsMarried
        {
            
get;
            
set;
        }

        
public string[] Names
        {
            
get;
            
set;
        }

        
public int[] Ages
        {
            
get;
            
set;
        }
        
public House MyHouse
        {
            
get;
            
set;
        }
        
public DateTime BirthDay
        {
            
get;
            
set;
        }
        
public List<string> Friends
        {
            
get;
            
set;
        }
        
public List<int> LoveNumbers
        {
            
get;
            
set;
        }
    }

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-06-02
  • 2021-12-16
  • 2022-12-23
  • 2022-12-23
  • 2021-10-10
猜你喜欢
  • 2021-12-28
  • 2021-11-09
  • 2022-12-23
  • 2022-01-27
相关资源
相似解决方案