I liked the Karhgath solution, but I did not want to use Json.Net, since I had a list with key / value pairs. Therefore, to build the Karhgath solution, I just got stuck in the dictionary:
public static string ToJson(ResourceManager rm) { Dictionary<string, string> pair = new Dictionary<string, string>(); ResourceSet resourceSet = rm.GetResourceSet(CultureInfo.CurrentUICulture, true, true); resourceSet.Cast<DictionaryEntry>().ToDictionary(x => x.Key.ToString(), x => x.Value.ToString()); string json = ""; foreach (DictionaryEntry item in resourceSet) { if (json != "") { json += ", "; } json += "\"" + item.Key + "\": \"" + item.Value + "\""; } return "{ " + json + " }"; }
Semanticzen
source share