wis3guy / HalClient.Net

A library that simplifies interaction with API's that respond with the "application\hal+json" media type.
Microsoft Public License
19 stars 21 forks source link

Allow _embedded to be null and not fail the parse. #8

Closed jabbera closed 8 years ago

jabbera commented 8 years ago

This happens if there server is using:

JsonFormatter.SerializerSettings.NullValueHandling = NullValueHandling.Include

wis3guy commented 8 years ago

Thank you for creating this pull request. To be honest, i'm unsure that the library should support this though. If it does, the same rules should apply to the _links property.

My reasoning: Both _links and _embedded are optional in a resource. I interpret this as a) they can be there as objects according to the specified format, or b) they are not there. Accepting null as a value adds option c. If we go down this route, we should explicitly allow only null imho.

What do you think.

jabbera commented 8 years ago

i think null explicitly needs to be supported. If you use a serializer that outputs all fields even if they are null, which is valid, then this library won't work. Right now the code supports links, but I didn't add a test. Will do that now. It also will accept white space as well as null. I'll make the check more explicit.

jabbera commented 8 years ago

Sorry for the delay on the update. This should address your concerns.