I want to take a JSON string and map it to a dictionary so I can have access to its key-value pairs and then check the values after. I keep getting an error:
Unable to cast object of type
Newtonsoft.Json.Linq.JObjectto typeSystem.Collections.Generic.IDictionary [System.String,System.Object].string
IDictionary<string, object> dict = (IDictionary<string, object>)source;
source is from the JSON string.
Instead of explicit casting from
JObjecttoDictionary, useJObject.ToObject<T>().