{“15 天”:“675”,“180 天”:“8100”,“30 天”:“1350”,“60 天”:“2700”,“90 天”:“4050”}
问问题
39 次
1 回答
0
我们可以将此 json 转换为字典。并以这种方式处理这种情况。因为我们可以直接反序列化为类对象。
var test = "{ \"15 Days\": \"675\", \"180 Days\": \"8100\",
\"30 Days\": \"1350\", \"60 Days\": \"2700\", \"90 Days\":
\"4050\" }";
string [] json = test.Replace("{",
string.Empty).Replace("}", string.Empty).Split(',');
Dictionary<string, string> jsonDic = new Dictionary<string, string>();
for (int i = 0; i < json.Length; i++)
{
string[] jsonItem = json[i].Split(':');
jsonDic.Add(jsonItem[1], jsonItem[0]);
}
这个字典 jsonDic 如下所示。
希望这对你有帮助。
于 2020-08-31T10:33:01.723 回答