I need someone wiser than myself to guide me to creating some nested dictionaries in C#. I'm trying to create a post in restsharp that would ultimately resemble this sample json:
{
"brandId": 34344,
"collectionId": 5,
"productTypeId": 1,
"identity": {
"sku": "SKU0001",
"ean": "12323423",
"upc": "543534563",
"isbn": "54353453",
"barcode": "45453"
},
"stock": {
"stockTracked": true,
"weight": {
"magnitude": 4324.54
}
},
"financialDetails": {
"taxable": false,
"taxCode": {
"id": 7,
"code": "T20"
}
},
"salesChannels": [
{
"salesChannelName": "Brightpearl",
"productName": "Product B",
"productCondition": "new",
"categories": [
{
"categoryCode": "276"
},
{
"categoryCode": "295"
}
],
"description": {
"languageCode": "en",
"text": "Some description",
"format": "HTML_FRAGMENT"
},
"shortDescription": {
"languageCode": "en",
"text": "Some description",
"format": "HTML_FRAGMENT"
}
}
],
"seasonIds": [
1,
2,
3
],
"nominalCodeStock": "1000",
"nominalCodePurchases": "5000",
"nominalCodeSales": "4000",
"reporting": {
"seasonId": 3,
"categoryId": 295,
"subcategoryId": 298
}
}
I have not tried to created nested dictionaries before. My experiences has been more limited to this:
Dictionary<string, string> values = new Dictionary<string, string>
{
{ "brandid", "1234" },
{ "productTypeId", "11" }
};
string json = JsonConvert.SerializeObject(values);
List<Dictionary<string, string>> ld = new List<Dictionary<string, string>>
{
values
};
request2.AddJsonBody(ld);
Some help pointing me in the right direction would be immensely appreciated.