我讀取了我的 json 文件并設置了一個字符串變量,我正在使用 System.Web.Script.Serialization; FileStream fs = new FileStream(Server.MapPath("odul_en.json"),FileMode.Open,FileAccess.Read); StreamReader sr = new StreamReader(fs); string jsonGelen = sr.ReadToEnd(); var serializer = new JavaScriptSerializer(); var dict = serializer.Deserialize<Dictionary<string, object>>(jsonGelen);當我把斷點“var dict= serializer.Deserialize>(jsonGelen);” 行,我收到以下錯誤;System.Collections.Generic.Dictionary`2[[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Object, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken =b77a5c561934e089]]'odul_en.json 像這樣; [{"odulID": "130","Ad": "LaQ Creative Toy / Basic 001","Aciklama": "Instead of the gift product, the product is not paid for the price, can not be turned into money. There is no guarantee of the products because of collective purchase. Buying gift product is not returned. Photos are representative, products may vary."},{"odulID": "132","Ad": "Selfie Stick","Aciklama": "Instead of the gift product, the product is not paid for the price, can not be turned into money. There is no guarantee of the products because of collective purchase. Photos are representative, products may vary. Buying gift product is not returned. There is no color option. Suitable for Phones, easy to carry. The open length is 100 cm and the closed length is 23 cm"}]我搜索了解決方法;有人在json文件中說“刪除方括號”但沒有解決。(我的 .net 框架 3.5 不能使用動態)我該如何解決這個問題,謝謝。
- 2 回答
- 0 關注
- 195 瀏覽
添加回答
舉報
0/150
提交
取消