我想在文本框中显示每个内容:
{"hash": "somehashencryption", "ip": "this.is.the.ip", "maxplayers": 64, "mppass": "3e6876ca64423fc478073f511dc7e11a", "name": "Name of the server", "players": 0, "port": 25565, "uptime": 2050648}
以这种形式:
name = Name of the server
ip = this.is.the.ip
mppass = 3e6876ca64423fc478073f511dc7e11a
port = 25565
uptime = 2050648
hash = somehashencryption
我在编码方面非常基础,我正在尝试将其转换为列表,有一个API:
答案 0 :(得分:0)
使用http://json2csharp.com/将您的示例输入转换为如下类:
public class ServerListItem
{
public string hash { get; set; }
public string ip { get; set; }
public int maxplayers { get; set; }
public string mppass { get; set; }
public string name { get; set; }
public int players { get; set; }
public int port { get; set; }
public int uptime { get; set; }
}
反序列化并使用如下数据:
var s = "{\"hash\": \"somehashencryption\", \"ip\": \"this.is.the.ip\", \"maxplayers\": 64, \"mppass\"" +
": \"3e6876ca64423fc478073f511dc7e11a\", \"name\": \"Name of the server\", \"players\": 0" +
", \"port\": 25565, \"uptime\": 2050648}";
var server = JsonConvert.DeserializeObject<ServerListItem>(s);
Console.WriteLine("Hash: " + server.hash);