日常工作中可能会遇到如何用C#转换为JSON字符串
using System;
using System.Collections.Generic;
Dictionary<string, string> Content = new Dictionary<string, string>();
Content.Add("str1", "str1");
Content.Add("str2", "str2");
Content.Add("str3", "str3");
//Dictionary转json
string Contentjson = JsonConvert.SerializeObject(Content);
Console.WriteLine(Contentjson);
输出结果如下:
{"str1":"str1","str2":"str2","str3":"str3"}