Hi I have the following classes.
As you can see there is a Body portion and I have created a json based off of this, however my question is:
Suppose we ignore the Body portion of this, and we just focus on Payment, Items, and Receipt...is there a way to programatically on the fly create a json based off of these three classes? Pretend the Body class is non-existent.
What would something like this look like?
public class Payment
{
public string Amount { get; set; }
}
public class Receipt
{
public string Info { get; set; }
public string Amount { get; set; }
}
public class Items
{
public string SKU {get; set;}
}
public class Body
{
public List<Item> Items { get; set; }
public List<Payment> Payments { get; set; }
public Receipt Receipt { get; set; }
}
I have the json.net dll referenced I'm trying to figure out what I can do to get the three classes into a new class if hypothetically the Body class wasn't there and I had to make it on the fly.
Receipt test = new Receipt();
string DataJson = JsonConvert.SerializeObject(test, Newtonsoft.Json.Formatting.Indented, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
I can get the json individually like this however I want one json and formatted since the Items is a List as well as Payment, hopefully this makes sense.