This project has moved and is read-only. For the latest updates, please go here.

How do I get to exclude nulls when deseralizing a collection?

Jan 24, 2012 at 4:10 PM

I have json that I am getting back that potentially gets back nulls as part of the values. How can I, or is there even a way, to exclude those nulls from the collection?


         "id": "5551212",
         "from": {
            "name": "Message creator",
            "start_time": "2011-10-21T22:00:00",
            "end_time": "2011-10-23T17:00:00",
            "location": "area 51",
            "id": "2121212122"
         "to": {
            "data": [
                  "name": "Jay-Z",
                  "id": "77777"
                  "name": "Bill Murray",
                  "id": "88888"
                  "name": "Anthony Hopkins",
                  "id": "99999"
         "message": "Some message from somewhere",
         "updated_time": "2011-09-19T23:53:51+0000",
         "unread": 1,
         "unseen": 0

Notice between Bill Murray and Anthony Hopkins the null that is returned. Thanks.

Jan 24, 2012 at 8:57 PM

Ok, I pulled the source and started tinkering with it. It looks like the deserialization doesn't take into consideration the settings using the DeserializeObject<T>(String, JsonSerializerSettings) signature. I found a line where adding a fix seems to work. Any great idea on how i can add the patch and get into a release? The app we have that uses isn't pleased with this behavior.