I have the following json format that I need to change by removing the "root" element and then sending it for processing.
{
"deonItemDetails":[
{
"hsDesc":"",
"namePLU":"AGO LOCAL",
"taxRate":0.0,
"unitPrice":71.0,
"discount":0.0,
"hsCode":"",
"quantity":1.0,
"measureUnit":"Litres",
"vatClass":"A"
}
],
"root":{
"senderId":"a4031de9-d11f-4b52-8cca-e1c7422f3c37",
"invoiceCategory":"tax_invoice",
"traderSystemInvoiceNumber":"34058",
"relevantInvoiceNumber":"",
"pinOfBuyer":"P051400323I",
"invoiceType":"Original",
"exemptionNumber":"",
"totalInvoiceAmount":71.0,
"systemUser":"manager"
}
}
I need it to be like this:
{
"deonItemDetails":[
{
"hsDesc":"",
"namePLU":"AGO LOCAL",
"taxRate":0.0,
"unitPrice":71.0,
"discount":0.0,
"hsCode":"",
"quantity":1.0,
"measureUnit":"Litres",
"vatClass":"A"
}
],
"senderId":"a4031de9-d11f-4b52-8cca-e1c7422f3c37",
"invoiceCategory":"tax_invoice",
"traderSystemInvoiceNumber":"34058",
"relevantInvoiceNumber":"",
"pinOfBuyer":"P051400323I",
"invoiceType":"Original",
"exemptionNumber":"",
"totalInvoiceAmount":71.0,
"systemUser":"manager"
}
However, using the following code, all content of root is removed instead of just the tag and brackets belinging to that node.
JObject jo = JObject.Parse(jsonToSendDetails);
jo.Property("root").Remove();
var newjson = jo.ToString();
How do I get the json to look like the 2nd one?