c# 将json数据转为键值对

 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",
        //}

 

转载于:https://www.cnblogs.com/macT/p/9871902.html

你可能感兴趣的:(c# 将json数据转为键值对)