string json = File.ReadAllText($"./assets/JSON/{mapName}.json");
Console.WriteLine(json);
var gridMapData = JsonConvert.DeserializeObject(json);
Здесь я десериализую объект, и в режиме выпуска он работает нормально. Но при собственной компиляции (PublishAot), как показано ниже:
Exe
net8.0
enable
enable
true
true
AnyCPU;x64;x86
app.manifest
True
true --> here
Эта ошибка Newtonsoft.Json.JsonSerializationException: невозможно найти конструктор.
начинается (из того же json и того же типа класса для десериализации это ). Кроме того, я вижу в Console.WriteLine, что строка json отображается правильно.
Буду благодарен за любую помощь или отзыв.
Я пытался устраните ошибку, изменив класс.
public class GridMapData
{
public int width;
public int height;
public Dictionary cells;
--> Things i tried
//public GridMapData(int Width, int Height, Dictionary Cells)
//{
// this.width = Width;
// this.height = Height;
// this.cells = Cells;
//}
//public GridMapData() { }
//[JsonConstructor]
//public GridMapData() { }
}
Подробнее здесь: https://stackoverflow.com/questions/785 ... onstructor