I have a JSON-string with a fixed number of arrays of different objects (created in Java with JSONObjects and JSONArrays):
[
[ //The first type of object
{
"Initials":"MUS"
},
{
"Initials":"NA"
}
],
[ //The second type
{
"ToolId":17
},
{
...
}
]
... //etc.
]
So I've created some Dummy-classes that has corresponding properties to the objects within the array, which works:
private class DummyEmployee
{
public string Initials { get; set; }
}
//etc.
But I can't figure out how the container class should be designed. This is how I did it:
private class DataContainer
{
public List<DummyEmployee> Employees { get; set; }
public List<DummySecondType> SecondTypes { get; set; }
//etc.
}
This is how I attempt to deserialize the JSON-data:
JavaScriptSerializer ser = new JavaScriptSerializer();
string jsonDataFromClient = ...;
DataContainer jsonData = ser.Deserialize<DataContainer>(jsonDataFromClient);
And it doesn't work. I get the following error while passing the data:
Type 'GUI.ValidateLoginData+DataContainer' is not supported for deserialization of an array.
I couldn't find any other subjects on the matter of deserializing arrays of different objects.