serialization - c# JavaScriptSerializer deserialize variable type field -


i trying deserialize json strings fields can different. these of strings have deserialize:

{"field1":{"array":[1,2,3]},"field2":{"array":["a","b","c"]}}

{"field1":"", "field2":""}

{"field1":"","field2":{"array":["a","b","c"]}}

{"field1":{"array":[1,2,3]},"field2":""}

the first string deserialized, remainder throws exception.

is possible parse 4 strings same code?

the reason why others throwing exception because deserialization target data type expecting object inside field1 , field2, in last three, have empty strings.

try replacing empty strings null.


Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -

php - $params->set Array between square bracket -