Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save MirzaMerdovic/c36822fc0552b108ec2c47d9760850a4 to your computer and use it in GitHub Desktop.
Save MirzaMerdovic/c36822fc0552b108ec2c47d9760850a4 to your computer and use it in GitHub Desktop.
Convert Newtonsoft.Json.Linq.JArray to System.Collections.Generic.Dictionary<,>
// If you have a serialized dictionary in your configuration for example, something like this:
// "dictionary": [{"1":"asda"}, {"2":"qweww"}, {"3":{"awdsd333"}]
Dictionary<int, string> parameters =
((JArray)serializedJArray)
.Children<JObject>()
.ToDictionary(x => int.Parse(x.Properties().First().Name), x => x.Properties().First().Value.ToString());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment