1

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?

2

1 Answer 1

4

Yes.

Inside the JsonConverter test the token type from the JsonReader.

If it is a string then return null.

If it is the start of an array then use the JsonReader and JsonSerializer passed to the converter method to deserialize the array.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.