Telling JSON to default to null if datatype does not match.

Sep 12, 2010 at 10:12 PM
Edited Sep 13, 2010 at 10:40 PM

Is that possible? 

If I have a JSON string that looks like:

"foo":{
"a":"111",
"b":"222",
},

and a class that looks like

foo() {

public a {get;set;} 

public b {get;set;}

}

 

but sometimes foo is 

"foo":[],
Is there a way to tell the deserializer to set my foo instance to NULL if the json string is of type array?
Thanks!