【发布时间】:2019-11-05 22:36:20
【问题描述】:
我是 C# REST API 的新手...我只是将 JSON 转换为字符串数组
这是我的 JSON
[{"Id":1000,"Name":"May","Address":"Atlanda","Country":"USA","Phone":12345}}
如下代码转换数组
string[] details={1000,May,Atlanda,USA,12345};
帮我解决这个问题
我的代码
public class details
{
public int Id { get; set; }
public string Name { get; set; }
public string Address { get; set; }
public string Country { get; set; }
public int Phone { get; set; }
}
这是我的课
var client = new RestClient("http://localhost:3000/customer/1000");
var request = new RestRequest(Method.GET);
IRestResponse response = client.Execute(request);
string json = new JavaScriptSerializer().Serialize(response.Content);
【问题讨论】:
-
A minimal reproducible example 在代码中定义了 json 会很棒。请务必指定您尝试生成的确切输出。
-
...
int Phone?这不能很好地处理国家/地区代码的前导零...... -
只有它的样本
-
您希望 JSON 字符串反序列化为
details类吗? -
No.. Json 到数组