Как генерировать метаданные JSON класса.Как получить метаданные класса в строку JSON
например.
C# Классы
public class Product
{
public int Id { get; set; }
public string Name { get; set; }
public bool IsActive { get; set; }
public Description Description { get; set; }
}
public class Description
{
public string Content { get; set; }
public string ShortContent { get; set; }
}
JSON
[
{
"PropertyName" : "Id",
"Type" : "Int",
"IsPrimitive" : true
},
{
"PropertyName" : "Name",
"Type" : "string",
"IsPrimitive" : true
},
{
"PropertyName" : "IsActive",
"Type" : "bool",
"IsPrimitive" : true
},
{
"PropertyName" : "Description",
"Type" : "Description",
"IsPrimitive" : false
"Properties" : {
{
"PropertyName" : "Content",
"Type" : "string",
"IsPrimitive" : true
},
{
"PropertyName" : "ShortContent",
"Type" : "string",
"IsPrimitive" : true
}
}
},
]
Таким образом, вы не хотите, чтобы значение, только описание типа? – Thomas
@Thomas Нет, мне просто нужна информация о члене класса, чтобы я мог передать его потребителю –
см. Мое сообщение, это должно делать то, что вы хотите. – Thomas