Skip to content

Commit

Permalink
Core: fix JsonPack readonly parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
KrzysFR committed Feb 9, 2024
1 parent c042c61 commit d3c9d2e
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions Doxense.Core/Serialization/JSON/JSONB/JsonPack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ private static JsonArray ParseArray(ref SliceReader reader, int token, CrystalJs
{
if (token == (int) TypeTokens.ArrayEmpty)
{
return JsonArray.Create(); //BUGBUG: TODO: readonly?
return JsonArray.EmptyReadOnly;
}

//note: ARRAY_START has already been parsed
Expand All @@ -784,11 +784,14 @@ private static JsonArray ParseArray(ref SliceReader reader, int token, CrystalJs
while ((next = reader.ReadByte()) != (int) TypeTokens.ArrayStop)
{
if (next < 0) throw new FormatException("Unexpected end of JSONPack Array.");
var val = ReadValue(ref reader, next, settings);
if (arr == null) arr = new JsonArray();
arr.Add(val ?? JsonNull.Null);
var val = (ReadValue(ref reader, next, settings) ?? JsonNull.Null);
arr ??= new JsonArray();
arr.Add(val);
#if DEBUG
if (!val.IsReadOnly) Contract.Fail("Parsed child was mutable even though the settings are set to Immutable!");
#endif
}
return arr ?? JsonArray.Create(); //BUGBUG: TODO: readonly?
return arr?.FreezeUnsafe() ?? JsonArray.EmptyReadOnly;
}

private static string? ParseSmallString(ref SliceReader reader, int token)
Expand Down

0 comments on commit d3c9d2e

Please sign in to comment.