Closed haagenson closed 10 years ago
@prabirshrestha can you take a look at the proposed changes? I'm looking to incorporate these changes into the octokit repository as well and was hoping to get your opinion.
Thank you!
@haagenson Your root is not a json array. So trying to deserialize to a ItemList
which is List<Item>
should fail and it does fail. Not understanding this PR. Care to elaborate?
//ccing @shiftkey since octokit is referenced.
@prabirshrestha I don't have control over the API that is delivering the object. The API returns List
My Test method is poorly named, it should be named something more along the lines of Can_Deserialize_Single_Root_Json_Object_To_Inherited_List.
@haagenson This doesn't actually make sense to include it in SimpleJson. Out of curiosity can you list the apis.
@haacked @shiftkey is there some parameters/headers you can send to always make it treat as lists?
I would love to see if any other vendors implements their api this way.
@haagenson Can you try this scenario by implementing your own IJsonSerializerStrategy
. In fact octokit.net is using its own strategy - GitHubSerializerStrategy
. Might be a patch there is a better solution instead. https://github.com/octokit/octokit.net/blob/9dacef686b0cfeaebea1248afd9d44029c6fe4c4/Octokit/Http/SimpleJsonSerializer.cs#L22
@prabirshrestha I'm performing a GET API Call for references. The API uses the same signature for a single reference or a list of references.
I can definitely implement it in the GitHubSerializerStrategy
instead. I think at this point I probably need more input from the GitHub guys on the direction they would like to go with this.
Yeah, definitely a GitHub issue.
Closing this for now due to discussion on the Github repository.
Thanks so much for the review and comments @prabirshrestha
There is a bug I found using Generic Lists when the object to be deserialized is not part of a collection and is rather an object. This includes two commits. The first commit is the failing unit test. The second commit is the code to fix the bug.