1.先创建一个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序列化
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using GongHuiNewtonsoft.Json;
using GongHuiNewtonsoft.Json.Serialization;
namespace JSONDemo
{
class Program
{
static void Main(string[] args)
{
Address address = new Address
{
Provinc