So here's my DTO, when I debug I CLEARLY see the Roles list populated... but in the endpoint /RestApi/myroute?format=json (or any format) there's nothing there. Tried changing List to a dto object, same deal.
public class PageItemDto {
public Guid Id { get; set; }
public Guid PageId { get; set; }
public Guid ParentId { get; set; }
public string Name { get; set; }
public float Ordinal { get; set; } = 0.0f;
public string RolesJson { get; set; }
public List<string> Roles = new List<string>();
}
If I then do
pageItem.RolesJson = ServiceStack.Text.JsonSerializer.SerializeToString(pageItem.Roles);
The RolesJson property shows what should be in the list...
What am I missing here, I SWEAR I've sent nested objects a billion times.
Only public properties are serialized by default, so your DTO should be changed to:
public class PageItem
{
public Guid Id { get; set; }
public Guid PageId { get; set; }
public Guid ParentId { get; set; }
public string Name { get; set; }
public float Ordinal { get; set; } = 0.0f;
public string RolesJson { get; set; }
public List<string> Roles { get; set; } = new List<string>();
}