在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
C# 将MSMQ消息转换成Json格式 【优化】 转换函数: private string ConvertToJSON(string label, string body) { //TODO: convert to json string[] Lablelist = label.Split('|'); string[] Bodylist = body.Split('|'); string JsonStr = "{\""; NameValueCollection nvc = (NameValueCollection)ConfigurationManager.GetSection("LableName"); foreach (string key in nvc.AllKeys) { JsonStr = JsonStr + nvc[key] + "\":\"" + Lablelist[Convert.ToInt32(key)-1] + "\",\""; } NameValueCollection nvd = (NameValueCollection)ConfigurationManager.GetSection("BodyName"); foreach (string key in nvd.AllKeys) { JsonStr = JsonStr + nvd[key] + "\":\"" + Bodylist[Convert.ToInt32(key) - 1] + "\",\""; } JsonStr = JsonStr.Remove(JsonStr.Length - 2, 2)+"}"; Console.WriteLine(JsonStr); return JsonStr; } 配置文件:
Thank you! |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论