-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Closed
Labels
Description
i have some code that serializes some data to file that errors when attempting to deserialize
i created a small test app that had no issues doing the same thing
until i use the JsonSerializerOptions from the original code
I copied the working options to the erroring code - it still errored
i serialized the 2 options objects and diff'd them - identical
why would the options object make any difference when they are exactly the same ?
public static readonly JsonSerializerOptions Jo = new JsonSerializerOptions
{
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
// WriteIndented = true,
ReferenceHandler = ReferenceHandler.Preserve,
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
};
dump("Jo",Jo);
dump("FMdb.Jo",Jo);
s1 = File.ReadAllText(path);
Console.WriteLine("Deserialize fmdb File local Jo");
j3 = JsonSerializer.Deserialize<DbJson>(s1, Jo);
Console.WriteLine("Deserialize fmdb File Fmdb.Jo");
j3 = JsonSerializer.Deserialize<DbJson>(s1, FMdb.Jo);
dump("Deserialized", j3);
---> System.Text.Json.JsonException: The JSON value could not be converted to System.Collections.Generic.List`1[FretboardMaster.Models.A]. Path: $.As | LineNumber: 0 | BytePositionInLine: 17.