❔ i cant return object in JSON correctly in asp.net core web app
i cant serialize object correctly, so im creating asp.net core web app, and i have model structured kie this:
public class Card
{
[Key]
public int Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public double Price { get; set; }
public double Price2 { get; set; }
public double Price3 { get; set; }
public double Price4 { get; set; }
public double MorePrices { get; set; }
[ValidateNever]
public string Image { get; set; }
public int Amount { get; set; }
[ValidateNever]
public int? CardId { get; set; }
[ForeignKey("CardId")]
[ValidateNever]
public Card Parent { get; set; }
[ValidateNever]
public int TypeId { get; set; }
[ForeignKey("TypeId")]
[ValidateNever]
public Type Type { get; set; }
[ValidateNever]
public DateTime Created_at { get; set; }
[ValidateNever]
public DateTime Updated_at { get; set; }
[ValidateNever]
[NotMapped]
public List<Card>? Appendices { get; set; }
}
and i have API that pull this this item from db, and populate appendices with items that have CardId equals to id of this exec item. Now api returns that object in JSON, and i got completly unreadable JSON format, i use JSON formatter on chrome but it wont format it as other objects without Appendices. i tried fetching it but it wont. What i am doing wrong?
public class Card
{
[Key]
public int Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public double Price { get; set; }
public double Price2 { get; set; }
public double Price3 { get; set; }
public double Price4 { get; set; }
public double MorePrices { get; set; }
[ValidateNever]
public string Image { get; set; }
public int Amount { get; set; }
[ValidateNever]
public int? CardId { get; set; }
[ForeignKey("CardId")]
[ValidateNever]
public Card Parent { get; set; }
[ValidateNever]
public int TypeId { get; set; }
[ForeignKey("TypeId")]
[ValidateNever]
public Type Type { get; set; }
[ValidateNever]
public DateTime Created_at { get; set; }
[ValidateNever]
public DateTime Updated_at { get; set; }
[ValidateNever]
[NotMapped]
public List<Card>? Appendices { get; set; }
}
and i have API that pull this this item from db, and populate appendices with items that have CardId equals to id of this exec item. Now api returns that object in JSON, and i got completly unreadable JSON format, i use JSON formatter on chrome but it wont format it as other objects without Appendices. i tried fetching it but it wont. What i am doing wrong?


