Is there a way with the JavaScriptSerializer (I don't want to use another library at this time) where I can do something like this?
class Model
{
string[] Values { get; set; }
}
// using the serializer
JavaScriptSerializer serializer = new JavaScriptSerializer();
// this works
Model workingModel = serializer.Deserialize<Model>("{ Values : ['1234', '2346'] }");
// this works
Model wontWorkModel = serializer.Deserialize<Model>("{ Values : 'test' }");
I want wontWorkModel.Values to be an array with 1 item - test.
Is this possible with the JSON I've specified?
Edit
I was able to hack this in using a TypeConverter and inserting it into the type of string[], but it seems very hackish (and scary that I can do that in .NET).