c# 将json数据转为键值对

时间:2023-01-05 09:42:58
 string json = "{\"orderId\":\"000001\",\"haha\":\"001\",\"测试\":\"003\",\"goodsId[10]\":\"new data\"}";
JObject jsonObj = JsonConvert.DeserializeObject(json) as JObject;
foreach (var p in jsonObj.Properties().ToArray())
Console.WriteLine("key={0}, value={1}", p.Name, jsonObj[p.Name].Value<string>());
//{
//"orderId":"000001",
//"haha":"001",
//"测试":"003",
//"goodsId[10]":"new data",
//}