我想動態解析JSON數據並讀取它的鍵和它們的值,而無需將它序列化到具體的類中,因爲JSON數據可能會有不同的時間。但是對於最初的測試,一個樣本數據就是這樣的。在這個數據中,我想獲取屬性值,如果JSON數據也包含複雜的結構,我也想讀取子屬性值如何在C#中做到這一點。解析JSON數據並讀取其屬性值
{"id":4877891717,"email":"[email protected]","accepts_marketing":true,"created_at":"2017-03-24T08:39:56+01:00","updated_at":"2017-04-10T09:40:42+02:00","first_name":"Robin","last_name":"Van Persie","orders_count":8,"state":"disabled","total_spent":"2320.00","last_order_id":4434634693,"note":"","verified_email":true,"multipass_identifier":null,"tax_exempt":true,"phone":"+3225551212","tags":"","last_order_name":"#1116","addresses":[{"id":5143111941,"first_name":"Robin","last_name":"Van Persie","company":"InSync","address1":"CB 28, El Solo Road","address2":"CB 28, El Solo Road","city":"Brussels","province":"EU","country":"Belgium","zip":"123456","phone":"12345678","name":"Robin Van Persie","province_code":null,"country_code":"BE","country_name":"Belgium","default":true}],"default_address":{"id":5143111941,"first_name":"Robin","last_name":"Van Persie","company":"InSync","address1":"CB 28, El Solo Road","address2":"CB 28, El Solo Road","city":"Brussels","province":"EU","country":"Belgium","zip":"123456","phone":"12345678","name":"Robin Van Persie","province_code":null,"country_code":"BE","country_name":"Belgium","default":true}}
我正在嘗試這種方式。但是在接下來我會做什麼。
foreach (JObject token in jObject.Children())
{}
感謝
你試圖使用索引,而不是關鍵...? –