我有一個json對象,它已被轉換爲字典列表。將JSON如下:如何遍歷C#中的通用字典列表#
{
"DataList":
{"Non Fuel":
{
"sn":"/DataXmlProduct/Customers/DataXml/Customer/DueDate",
"ItemCode":"/DataXmlProduct/Customers/DataXml/Customer/InvoiceNo",
"Qty":"/DataXmlProduct/Customers/DataXml/Customer/CustomerNo",
"Amount":"DataXml/Customer/TotalCurrentCharges"
},
"Fuel":{
"sn":"/DataXmlProduct/Customers/DataXml/Customer/InvoiceNo",
"ItemCode":"/DataXmlProduct/Customers/DataXml/Customer/InvoiceNo",
"Amount":"DataXml/Customer/TotalCurrentCharges"
}
}
}
結果是(Dictionary<string, object>
),每個字典這裏的價值又是一本字典,我需要通過字典的每個值動態迭代,並獲得最後的關鍵&值,其中該值是一個Xpath,需要從xpath獲取值。 請幫助我解決方案來遍歷字典。它應該是通用的,因爲json格式可以根據用戶輸入而變化。