mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-09 21:09:51 +00:00
bugfix - dictionaries are enumerable - we shouldn't enforce this serialization rule
This commit is contained in:
@@ -48,12 +48,15 @@ namespace Octokit.Internal
|
||||
{
|
||||
var body = response.Body;
|
||||
// simple json does not support the root node being empty. Will submit a pr but in the mean time....
|
||||
if (body != "{}")
|
||||
if (body != "{}")
|
||||
{
|
||||
var typeIsDictionary = typeof(IDictionary).IsAssignableFrom(typeof(T));
|
||||
var typeIsEnumerable = typeof(IEnumerable).IsAssignableFrom(typeof(T));
|
||||
var responseIsArray = body.StartsWith("{", StringComparison.Ordinal);
|
||||
|
||||
// If we're expecting an array, but we get a single object, just wrap it.
|
||||
// This supports an api that dynamically changes the return type based on the content.
|
||||
if ((typeof(IEnumerable).IsAssignableFrom(typeof(T)))
|
||||
&& body.StartsWith("{", StringComparison.Ordinal))
|
||||
if (!typeIsDictionary && typeIsEnumerable && responseIsArray)
|
||||
{
|
||||
body = "[" + body + "]";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user