I am trying to find a way to serialize object to json string in the following format, so I can meet project requirements
{
"id": 123456,
"los": {
"2019-05-13": [
{
"currency": "EUR",
"guests": 2,
"price": [
100,
200
]
},
{
"currency": "EUR",
"guests": 3,
"price": [
150,
250
]
}
],
"2019-05-14": {
"currency": "EUR",
"guests": 2,
"price": [
300
]
}
},
}
I created these model classes:
public class Rootobject
{
public Los los { get; set; }
public int Id { get; set; }
}
public class Los
{
public Item[] items{ get; set; }
}
public class Item
{
public DateTime date {get;set;}
public string currency { get; set; }
public int guests { get; set; }
public int[] price { get; set; }
}
It is possible somehow to change the name of an element during serialization, so Item is serialized as "2019-05-13", "2019-05-14" etc?