C# 代码:将 JSON 字符串转换为 Dictionary<string, string>
using System; using System.Collections.Generic; using Newtonsoft.Json;
public class Program { public static void Main(string[] args) { string json = @"{"format":"json","isnew":false,"membername":null,"memberid":null,"memo":"不想要了","method":"ome.refund.add","money":"20","node id":"1808165934","order bn":"170823210481717","pay_type":"online","refund bn":"20091110005","refund_type":"apply","status":"0","refundamount":199.11,"t_ready":"2017-09-11 11:17:44","t sent":"2017-09-11 11:17:44","timestamp":"2017-09-12 11:17:44:182739","trade no":"2017083121001001030288947070","v":"1.0","sign":"20449399271C98727AFFBA070A0FE30E"}";
Dictionary<string, string> dictionary = JsonConvert.DeserializeObject<Dictionary<string, string>>(json);
foreach (KeyValuePair<string, string> kvp in dictionary)
{
Console.WriteLine("Key: " + kvp.Key + ", Value: " + kvp.Value);
}
}
}
原文地址: https://www.cveoy.top/t/topic/qlrZ 著作权归作者所有。请勿转载和采集!