mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-02 02:45:32 +00:00
Json deserializer always returns an object even when no fields were present, but other calling code was expecting a null to be returned if deserialization failed.
Deserializer now only instantiates object when at least 1 field was found, otherwise null is returned
This commit is contained in:
committed by
Brendan Forster
parent
f5359cdf7c
commit
cd503f2c67
@@ -1486,12 +1486,17 @@ namespace Octokit
|
||||
obj = value;
|
||||
else
|
||||
{
|
||||
obj = ConstructorCache[type]();
|
||||
foreach (KeyValuePair<string, KeyValuePair<Type, ReflectionUtils.SetDelegate>> setter in SetCache[type])
|
||||
{
|
||||
object jsonValue;
|
||||
if (jsonObject.TryGetValue(setter.Key, out jsonValue))
|
||||
{
|
||||
// Create object if it hasn't been created yet
|
||||
if (obj == null)
|
||||
{
|
||||
obj = ConstructorCache[type]();
|
||||
}
|
||||
|
||||
jsonValue = DeserializeObject(jsonValue, setter.Value.Key);
|
||||
setter.Value.Value(obj, jsonValue);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user