{"success":true,"code":"0","message":"success","data":{"result":"峡缆贡","id":"ZZEuMTMyRIyaL0Xz_gXdmQ"}",这段json在C#获取"峡缆贡",并且变成 ["峡","缆","贡"]
时间: 2023-10-01 13:04:29 浏览: 70
C#的json数据格式转化
在C#中获取"峡缆贡"并将其变为 ["峡","缆","贡"] 的步骤如下:
```csharp
using System;
using Newtonsoft.Json;
public class Data
{
public string result { get; set; }
}
public class Root
{
public bool success { get; set; }
public int code { get; set; }
public string message { get; set; }
public Data data { get; set; }
}
public class Program
{
public static void Main()
{
string json = "{\"success\":true,\"code\":\"0\",\"message\":\"success\",\"data\":{\"result\":\"峡缆贡\",\"id\":\"ZZEuMTMyRIyaL0Xz_gXdmQ\"}}";
Root root = JsonConvert.DeserializeObject<Root>(json);
string result = root.data.result; // 获取 "峡缆贡"
string[] characters = result.Split(""); // 将字符串拆分为 ["峡","缆","贡"]
foreach (var character in characters)
{
Console.WriteLine(character);
}
}
}
```
阅读全文