public static void Main()
Invoice fullInvoice = new Invoice
Vendor = new Vendor { Id = "vendorId", Name = "vendor name", BankAccount = "123asd123asd" },
HeldToDate = DateTime.Now.AddDays(30),
DownloadedDate = DateTime.Now,
ImportMsg = "some import message",
var makeJsonPrettyOption = new JsonSerializerOptions { WriteIndented = true };
var fullInvoiceJson = JsonSerializer.Serialize(fullInvoice, makeJsonPrettyOption);
var reducedInvoiceJson = JsonSerializer.Serialize<IReducedInvoice>(fullInvoice, makeJsonPrettyOption);
Console.WriteLine($"fullInvoice\n{fullInvoiceJson}");
Console.WriteLine($"reducedInvoice\n{reducedInvoiceJson}");
public class Invoice : IReducedInvoice
public string Id { get; set; }
public Vendor Vendor { get; set; }
public decimal Total { get; set; }
public string Status { get; set; }
public int DeliveryCount { get; set; }
public object HeldToDate { get; set; }
public string ErrorCode { get; set; }
public DateTime DownloadedDate { get; set; }
public string ImportMsg { get; set; }
IReducedVendor IReducedInvoice.Vendor { get => Vendor; }
public class Vendor : IReducedVendor
public string Id { get; set; }
public string Name { get; set; }
public string BankAccount { get; set; }
public interface IReducedInvoice
public string Id { get; set; }
public IReducedVendor Vendor { get; }
public decimal Total { get; set; }
public string Status { get; set; }
public interface IReducedVendor
public string Id { get; set; }
public string Name { get; set; }