Skip to content

Commit

Permalink
JSON: fix regression in JsonNull.GetValueOrDefault() for Span/Memory …
Browse files Browse the repository at this point in the history
…keys

- should return Missing instead of throwing an exception
  • Loading branch information
KrzysFR committed Jun 28, 2024
1 parent 5492116 commit f594218
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Doxense.Core/Serialization/JSON/ObjectModel/JsonNull.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,20 @@ public override JsonValue this[string key]

public override JsonValue GetValueOrDefault(string key, JsonValue? defaultValue = null) => defaultValue ?? JsonNull.Missing;

public override JsonValue GetValueOrDefault(ReadOnlyMemory<char> key, JsonValue? defaultValue = null) => defaultValue ?? JsonNull.Missing;

public override JsonValue GetValueOrDefault(ReadOnlySpan<char> key, JsonValue? defaultValue = null) => defaultValue ?? JsonNull.Missing;

public override JsonValue GetValueOrDefault(int index, JsonValue? defaultValue = null) => defaultValue ?? JsonNull.Missing;

public override JsonValue GetValueOrDefault(Index index, JsonValue? defaultValue = null) => defaultValue ?? JsonNull.Missing;

public override JsonValue GetValue(string key) => JsonValueExtensions.FailFieldIsNullOrMissing(this, key);

public override JsonValue GetValue(ReadOnlyMemory<char> key) => JsonValueExtensions.FailFieldIsNullOrMissing(this, key.Span);

public override JsonValue GetValue(ReadOnlySpan<char> key) => JsonValueExtensions.FailFieldIsNullOrMissing(this, key);

public override JsonValue GetValue(int index) => JsonValueExtensions.FailIndexIsNullOrMissing(index, JsonNull.Error);

public override JsonValue GetValue(Index index) => JsonValueExtensions.FailIndexIsNullOrMissing(index, JsonNull.Error);
Expand Down

0 comments on commit f594218

Please sign in to comment.