首页 新闻 会员 周边 捐助

.net json解析 求助

0
悬赏园豆:10 [已解决问题] 解决于 2020-03-20 10:51

[{"pid":"49","pgid":"4","pname":"全能虚拟主机400","pstock":"-1","pdes":"<p>功能说明:支持php5.2-PHP7.1 自由切换,独立管理面板,30天自动云端备份.数据库需单独购买,禁止大文件下载!</p>","phidden":"0","pprice":{"cprice":"420","onetime":"150","cycle":"12","pmothod":"1"},"pconfig":{"Connections":"0","WebSize":"400","MsSqlSize":"-1","MySqlSize":"-1","DomainSum":"0","productid":"19"},"pupgrade":"{}","psconfig":{"time_cycle":"0","nastock":"0","pricedes":"","trial_hours":"0","referralrate":"0","servicestatus":"-1","buylimit":"0"}},{"pid":"48","pgid":"4","pname":"全能虚拟主机300","pstock":"-1","pdes":"<p>功能说明:支持asp、.net2.0-net4.7 自由切换,独立控制面板,30天自动云端备份,数据库需单独购买,禁止大文件下载!</p>","phidden":"0","pprice":{"cprice":"320","onetime":"100","cycle":"12","pmothod":"1"},"pconfig":{"Connections":"0","WebSize":"300","MsSqlSize":"-1","MySqlSize":"-1","DomainSum":"0","productid":"19"},"pupgrade":"{}","psconfig":{"time_cycle":"0","nastock":"0","pricedes":"","trial_hours":"0","referralrate":"0","servicestatus":"-1","buylimit":"0"}},{"pid":"45","pgid":"4","pname":"全能虚拟主机200","pstock":"-1","pdes":"<p>功能说明:支持asp、.net2.0-net4.7 自由切换,独立控制面板,30天自动云端备份,数据库需单独购买,禁止大文件下载!</p>","phidden":"0","pprice":{"cprice":"220","onetime":"50","cycle":"12","pmothod":"1"},"pconfig":{"Connections":"0","WebSize":"200","MsSqlSize":"-1","MySqlSize":"-1","DomainSum":"0","productid":"19"},"pupgrade":"{}","psconfig":{"time_cycle":"0","nastock":"0","pricedes":"","trial_hours":"0","referralrate":"0","servicestatus":"-1","buylimit":"0"}},{"pid":"42","pgid":"4","pname":"全能虚拟主机100","pstock":"-1","pdes":"<p>功能说明:支持php5.2-PHP7.1 自由切换,独立管理面板,30天自动云端备份.数据库需单独购买,禁止大文件下载!</p>","phidden":"0","pprice":{"cprice":"120","onetime":"10","cycle":"12","pmothod":"1"},"pconfig":{"Connections":"0","WebSize":"100","MsSqlSize":"0","MySqlSize":"0","DomainSum":"0","productid":"19"},"pupgrade":"{}","psconfig":{"time_cycle":"0","nastock":"0","pricedes":"","trial_hours":"24","nodiscount":"1","referralrate":"0","servicestatus":"-1","buylimit":"0"}}]
——————————————————————————————————————
想取到 pid 和 pconfig下面的WebSize

中国农业网zgny的主页 中国农业网zgny | 初学一级 | 园豆:81
提问于:2020-03-18 15:01
< >
分享
最佳答案
1
//简化的entity 对象
class Dto{
public string Pid{get;set;}
public PConfig Pconfig{get;set;}
}
class PConfig{
public int WebSize{get;set;}
}

var arr=  Newtonsoft.Json.JsonConvert.DeserializeObject<Dto[]>("your json string");
foreach(var item in arr){
     item.pid;
     item.pconfig.WebSize;
}
//自动生成的entity对象
public class Dto
    {
        public string pid { get; set; }
        public string pgid { get; set; }
        public string pname { get; set; }
        public string pstock { get; set; }
        public string pdes { get; set; }
        public string phidden { get; set; }
        public Pprice pprice { get; set; }
        public Pconfig pconfig { get; set; }
        public string pupgrade { get; set; }
        public Psconfig psconfig { get; set; }
    }

    public class Pprice
    {
        public string cprice { get; set; }
        public string onetime { get; set; }
        public string cycle { get; set; }
        public string pmothod { get; set; }
    }

    public class Pconfig
    {
        public string Connections { get; set; }
        public string WebSize { get; set; }
        public string MsSqlSize { get; set; }
        public string MySqlSize { get; set; }
        public string DomainSum { get; set; }
        public string productid { get; set; }
    }

    public class Psconfig
    {
        public string time_cycle { get; set; }
        public string nastock { get; set; }
        public string pricedes { get; set; }
        public string trial_hours { get; set; }
        public string referralrate { get; set; }
        public string servicestatus { get; set; }
        public string buylimit { get; set; }
        public string nodiscount { get; set; }
    }
收获园豆:10
czd890 | 专家六级 |园豆:14488 | 2020-03-18 16:12
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册