It seems like a direct conversion to a dictionary may not be possible... I believe the deserializer
requires a corresponding type with clear property names and types.
One approach could be to convert to a type
, then generate a dictionary
as shown below:
public class MyClass
{
public List<bool> Symptom { get; set; }
public List<bool> Action { get; set; }
public bool AllArea { get; set; }
public Dictionary<string, List<bool>> GetDictionary()
{
var dataDictionary = new Dictionary<string, List<bool>>();
dataDictionary.Add("Symptom", this.Symptom);
dataDictionary.Add("Action", this.Action);
dataDictionary.Add("AllArea", new List<bool>() { AllArea });
return dataDictionary;
}
}
Then you can deserialize and retrieve the dictionary like so:
string inputData = "{\"Symptom\":[true,true,true],\"Action\":[true,true],\"AllArea\":true}";
System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
var objectData = serializer.Deserialize<MyClass>(inputData);
var outputDictionary = objectData.GetDictionary();
In any case, it was an interesting question.