Мы уже показывали этот трюк, и сейчас напомним, потому что он спасает часы ручного набора классов. В
Visual Studio Edit → Paste Special → Paste JSON As Classes генерирует классы из JSON в буфере, включая атрибуты сериализации.Пример:
"Colors": [
{
"numberKey": 1,
"isPrimary": true,
"listColors": ["Red", "Blue", "Yellow"]
},
{
"numberKey": 2,
"isPrimary": false,
"listColors": ["Purple", "Green", "Orange"]
}
]
}
Сгенерированный C# код:
public class Root
{
public Color[] Colors { get; set; }
}
public class Color
{
public int NumberKey { get; set; }
public bool IsPrimary { get; set; }
public string[] ListColors { get; set; }
}
📍 Навигация: Вакансии • Задачи • Собесы
🐸Библиотека шарписта
#лучшее_из_библиотеки_2025