日期:2014-05-17  浏览次数:21105 次

C# 如何解析PHP 封装的JSON
{"Content":[{"ID":"1","PHONENUM":"13751479852","SENDSMS":"YE","SENDPHONE":"10086"},{"ID":"2","PHONENUM":"13751479852","SENDSMS":"YE","SENDPHONE":"10086"},{"ID":"3","PHONENUM":"13751479852","SENDSMS":"YE","SENDPHONE":"10086"},{"ID":"4","PHONENUM":"13751479852","SENDSMS":"YE","SENDPHONE":"10086"},{"ID":"5","PHONENUM":"13751479852","SENDSMS":"YE","SENDPHONE":"10086"},{"ID":"6","PHONENUM":"13751479852","SENDSMS":"YE","SENDPHONE":"10086"},{"ID":"7","PHONENUM":"13751479852","SENDSMS":"YE","SENDPHONE":"10086"},{"ID":"8","PHONENUM":"13751479852","SENDSMS":"YE","SENDPHONE":"10086"},{"ID":"9","PHONENUM":"13751479852","SENDSMS":"YE","SENDPHONE":"10086"},{"ID":"10","PHONENUM":"13751479852","SENDSMS":"YE","SENDPHONE":"10086"},{"ID":"11","PHONENUM":"13751479852","SENDSMS":"YE","SENDPHONE":"10086"},{"ID":"12","PHONENUM":"13751479852","SENDSMS":"YE","SENDPHONE":"10086"},{"ID":"13","PHONENUM":"13751479852","SENDSMS":"YE","SENDPHONE":"10086"}]} 


如何解析这样的PHP封装的JSON字符串
Json.NET  解析不了
只能解析没有[]  括号的

------解决方案--------------------
引用Newtonsoft.Json.dll,下载地址:http://download.csdn.net/detail/guwei4037/5853053
class Program
    {
        static void Main(string[] args)
        {
            string json = "{\"Content\":[{\"ID\":\"1\",\"PHONENUM\":\"13751479852\",\"SENDSMS\":\"YE\",\"SENDPHONE\":\"10086\"},{\"ID\":\"2\",\"PHONENUM\":\"13751479852\",\"SENDSMS\":\"YE\",\"SENDPHONE\":\"10086\"},{\"ID\":\"3\",\"PHONENUM\":\"13751479852\",\"SENDSMS\":\"YE\",\"SENDPHONE\":\"10086\"},{\"ID\":\"4\",\"PHONENUM\":\"13751479852\",\"SENDSMS\":\"YE\",\"SENDPHONE\":\"10086\"},{\"ID\":\"5\",\"PHONENUM\":\"13751479852\",\"SENDSMS\":\"YE\",\"SENDPHONE\":\"10086\"},{\"ID\":\"6\",\"PHONENUM\":\"13751479852\",\"SENDSMS\":\"YE\",\"SENDPHONE\":\"10086\"},{\"ID\":\"7\",\"PHONENUM\":\"13751479852\",\"SENDSMS\":\"YE\",\"SENDPHONE\":\"10086\"},{\"ID\":\"8\",\"PHONENUM\":\"13751479852\",\"SENDSMS\":\"YE\",\"SENDPHONE\":\"10086\"},{\"ID\":\"9\",\"PHONENUM\":\"13751479852\",\"SENDSMS\":\"YE\",\"SENDPHONE\":\"10086\"},{\"ID\":\"10\",\"PHONENUM\":\"13751479852\",\"SENDSMS\":\"YE\",\"SENDPHONE\":\"10086\"},{\"ID\":\"11\",\"PHONENUM\":\"13751479852\",\"SENDSMS\":\"YE\",\"SENDPHONE\":\"10086\"},{\"ID\":\"12\",\"PHONENUM\":\"13751479852\",\"SENDSMS\":\"YE\",\"SENDPHONE\":\"10086\"},{\"ID\":\"13\",\"PHONENUM\":\"13751479852\",\"SENDSMS\":\"YE\",\"SENDPHONE\":\"10086\"}]} ";
            Data data = JsonConvert.DeserializeObject<Data>(json);
            data.Content.ForEach(x => Console.WriteLine(string.Join(" ", x.ID, x.PHONENUM, x.SENDSMS, x.SENDPHONE)));
        }
    }

    public class Data
    {
        public List<Detail> Content { get; set; }
   &nb