我正在尝试将API响应淡化JSON [英] I'm trying to desalinize API response JSON

查看:73
本文介绍了我正在尝试将API响应淡化JSON的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

JSON对象如下所示:



{status:OK,data:{group_id:226369621,0:{ ID: 226369621-1, 的自订: , customid1: , customid2: , 手机: 34684426702, 状态: 期待已久的-DLR, country:ES}},message:1个号码的广告系列成功提交。}



我尝试过:



公共字符串groupid(字符串resp)

{



< br $>


var serializer = new JavaScriptSerializer();



var groupid = serializer.Deserialize< ids>(strResponse );







}

公共类ids

{



public string group_id {get;组; }

公共字符串状态{get;组; }

}

The JSON object looks like:

{"status":"OK","data":{"group_id":226369621,"0":{"id":"226369621-1","customid":"","customid1":"","customid2":"","mobile":"34684426702","status":"AWAITED-DLR","country":"ES"}},"message":"Campaign of 1 numbers Submitted successfully."}

What I have tried:

public string groupid(string resp)
{



var serializer = new JavaScriptSerializer();

var groupid = serializer.Deserialize<ids>(strResponse);



}
public class ids
{

public string group_id { get; set; }
public string status { get; set; }
}

推荐答案

根据你的json,请创建一个类似于下面的ResponseModel Generic Class并使用Newtonsoft Json Library



According to your json, Please create a ResponseModel Generic Class something like below and Use Newtonsoft Json Library

public class ResponseModel<T>
{
    public T data { get; set; }
    public string status { get; set; }
}





然后你可以解析你的json如下:





Then you can parse your json like below:

JsonConvert.DeserializeObject<ids>(json_Holder)


这篇关于我正在尝试将API响应淡化JSON的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆