2013-07-31 50 views
9

私は、JSON文字列をデコードするJSON.netを使用していると私はこのエラーを見つける:JSONデコード:予期しないトークン:StartArray

Exception in 'Newtonsoft.Json.JsonReaderException' en Newtonsoft.Json.dll

Información adicional: Error reading string. Unexpected token: StartArray. Path 'mentions', line 3, position 3.

は、JSON文字列は次のようなものです:

{ 
"mentions": 
    [ 
     { 
      "id":"1234", 
      "alert_id":123, 
      "title":"Bla bla bla", 
      "url":"http:\/\/www.example.com\/", 
      "unique_id":"123", 
      "published_at":"2013-07-30T11:26:36.92131100+00:00", 
      "created_at":"2013-07-30T11:27:08.0+00:00", 
      "updated_at":"2013-07-30T11:27:09.0+00:00", 
      "favorite":false, 
      "trashed":false, 
      "trashed_set_by_user":false, 
      "read":false, 
      "tone":0, 
      "tone_score":0.14732, 
      "relevance_score":1, 
      "source_type":"forums", 
      "source_name":"xxx", 
      "source_url":"http:\/\/example.com\/", 
      "language_code":"es", 
      "tasks":[], 
      "logs":[], 
      "children":[], 
      "picture_url":"https:\/\/example.com\/example.jpg" 
     }, 
     { 
      "id":"1235", 
      "alert_id":123, 
      "title":"Bla bla bla", 
      "url":"http:\/\/www.example.com\/", 
      "unique_id":"124", 
      "published_at":"2013-07-30T11:26:36.92131100+00:00", 
      "created_at":"2013-07-30T11:27:08.0+00:00", 
      "updated_at":"2013-07-30T11:27:09.0+00:00", 
      "favorite":false, 
      "trashed":false, 
      "trashed_set_by_user":false, 
      "read":false, 
      "tone":0, 
      "tone_score":0.14732, 
      "relevance_score":1, 
      "source_type":"forums", 
      "source_name":"xxx", 
      "source_url":"http:\/\/example.com\/", 
      "language_code":"es", 
      "tasks":[], 
      "logs":[], 
      "children":[], 
      "picture_url":"https:\/\/example.com\/example.jpg" 
     } 
    ], 
"recently_reenabled":false 
} 

とルックス3番目の行に問題があるようですが、 '['は配列の記述を開始しますが、このエラーは多かれ少なかれ解決方法が見つかりませんでした。

これは私のコードです:

Dim result As New Dictionary(Of String, String) 
    Dim serializer As New System.Web.Script.Serialization.JavaScriptSerializer 
    Dim jsonString As String 

    jsonString = txtJSON.Text 

    result = JsonConvert.DeserializeObject(Of Dictionary(Of String, String))(jsonString) 

ヘルプ?

答えて

12

JSONを逆シリアル化してDictionary(Of String, String)にしているようです。しかし、明らかにmentionsの値はStringではありません。これはオブジェクトの配列です。代わりにDictionary(Of String, Object)にデシリアライズしてみることもできます。