Skip to content

debugging Json.Deserialize error #114655

@germgerm

Description

@germgerm

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions