Deserialize JSON, sometimes value is an array, sometimes "" (blank string).

Posted by karl.r on Stack Overflow See other posts from Stack Overflow or by karl.r
Published on 2010-12-31T23:51:18Z Indexed on 2010/12/31 23:53 UTC
Read the original article Hit count: 161

Filed under:
|
|

I am trying to deserialize a field:

"presenters":[{...},{...}]

but some of the rows come back with only:

"presenters":""

When the serializer gets to the row with that empty string I get:

Error converting value "" to type 'System.Collections.Generic.List`1[DataPrototype.Model.Presenter]'.

Am I right in thinking that I need a JsonConverter that will change the empty string into an empty List?

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET