I have this string:
[{ "processLevel" : "1" , "segments" : [{ "min" : "0", "max" : "600" }] }]
I'm deserializing the object:
object json = jsonSerializer.DeserializeObject(jsonString);
The object looks like:
object[0] = Key: "processLevel", Value: "1"
object[1] = Key: "segments", Value: ...
And trying to create a dictionary:
Dictionary<string, object> dic = json as Dictionary<string, object>;
but dic gets null.
What can be the issue ?
Pravesh Singh
23-Dec-2013The problem is that the object is not of type Dictionary<string,object> or a compatible type, thus you can't cast directly. I would create a custom object and use Deserialize.
public class DeserializedObject{
public string processLevel{get;set;}
public object segments{get;set}
}
IEnumerable<DeserializedObject> object=jsonSerializer.Deserialize<IEnumerable<DeserializedObject>>(json)