How do I convert a JSON array like this
[{\"myKey\":\"myValue\"},
{\"anotherKey\":\"anotherValue\"}]
to a C# Dictionary wi
Its quite simple actually :
lets say you get your json in a string like :
string jsonString = @"[{"myKey":"myValue"},
{"anotherKey":"anotherValue"}]";
then you can deserialize it using JSON.NET as follows:
JArray a = JArray.Parse(jsonString);
// dictionary hold the key-value pairs now
Dictionary dict = new Dictionary();
foreach (JObject o in a.Children())
{
foreach (JProperty p in o.Properties())
{
string name = p.Name;
string value = (string)p.Value;
dict.Add(name,value);
}
}