是否有json格式的答案
{
"id": "161e6e624c78acfd7fd783844bc0adfa38c5135feb9170c9e8a05094ac41f11a1d87552aae3cd6544cecf7f3b8162edee7c01f5785c14f5ed11e1eee14e28619",
"name": "Geth/genom.minerpool.net/v1.8.0-unstable-8ec3861d/linux-amd64/go1.9.2",
"caps": [
"eth/62",
"eth/63"
],
"network": {
"localAddress": "192.168.1.3:8298",
"remoteAddress": "213.32.53.162:31337"
},
"protocols": {
"eth": {
"version": 63,
"difficulty": 121712103143555595,
"head": "0x7686acff7fa7560013bb6c7997c42d7f6adb0514277edbb7418e362b8e32bca2"
}
}
},
正在对请求进行脱盐的程序代码。
public class per
{
//[JsonProperty("network")]
public string localAddress { get; set; }
public string id { get; set; }
public string name { get; set; }
}
private void button2_Click(object sender, EventArgs e)
{
var peer = JsonConvert.DeserializeObject<List<per>>(richTextBox1.Text.ToString());
dataGridView2.DataSource = peers.Result;
}
问题是它没有在localAddres的datagridview中放置一个空白字段。我做错了什么?
答案 0 :(得分:0)
当JSON是一个单独的对象时,它被反序列化为一个集合。
使用另一个答案中定义的类,事件处理程序应按如下方式完成。
{ "publicKey": "XXX", "data": "XXX", "signature": "XXX" }