This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static Dictionary<string, string> ConvertJsonStr2Dictionary(string jsonStr) | |
{ | |
Dictionary<string, string> dict = new Dictionary<string, string>(); | |
int start = jsonStr.IndexOf("{", 1) + 2; | |
int stop = jsonStr.LastIndexOf("}}"); | |
jsonStr = jsonStr.Substring(start, stop - start - 1); | |
string[] keyValArr = jsonStr.Split(new string[] { "," }, StringSplitOptions.None); | |
foreach(string keyVal in keyValArr) | |
{ | |
string key = RemoveLeadingEndingQuotationMarks(keyVal.Substring(0, keyVal.LastIndexOf(":")).Trim()); | |
string val = RemoveLeadingEndingQuotationMarks(keyVal.Substring(keyVal.LastIndexOf(":") + 1).Trim()); | |
dict.Add(key, val); | |
} | |
return dict; | |
} |