Skip to content
This repository was archived by the owner on Dec 22, 2023. It is now read-only.

Commit 24ea5fa

Browse files
committed
correct a bug which prevent using null value in JSON when converting to an object
1 parent e04fe11 commit 24ea5fa

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Erasme.Http/Erasme.Json/JsonValue.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,14 +280,14 @@ object ToObjectInternal(Type type)
280280
if (!ContainsKey(field.Name))
281281
continue;
282282
var value = this[field.Name];
283-
field.SetValue(result, value.ToObjectInternal(field.FieldType));
283+
field.SetValue(result, value == null ? null : value.ToObjectInternal(field.FieldType));
284284
}
285285
foreach (var prop in type.GetProperties())
286286
{
287287
if (!ContainsKey(prop.Name))
288288
continue;
289289
var value = this[prop.Name];
290-
prop.SetValue(result, value.ToObjectInternal(prop.PropertyType));
290+
prop.SetValue(result, value == null ? null : value.ToObjectInternal(prop.PropertyType));
291291
}
292292
}
293293
else if (this is JsonArray)

0 commit comments

Comments
 (0)