0

我正在尝试从 twitter user_Stream api 提要中解析 json 内容,并尝试使用 json.net 和 javascriptserializer,但首先需要了解 json 的正确格式。文件内容不断给出一个错误,即存在一些无效的关闭或错过的关闭,我想知道是否有人知道 twitter user_stream 结果中一个帖子/活动的开始和结束标签是什么。在这个文件中,内容开始如下,以“转推”结束:假}]

[{"created_at":"Tue May 08 10:30:05 +0000   2012","id":199808381991653377,
   "id_str":"199808381991653377",
   "text":"@waddehawk Sorry for the misinformation earlier, this should be tomorrow after 2pm.",
   "source":"\u003cahref=\"http:\/\/www.awarenessnetworks.com\/home\/\"                              
   "truncated":false,
   "in_reply_to_status_id":199796940358156288,
   "in_reply_to_status_id_str":"199796940358156288",
     "in_reply_to_user_id":333905755,"in_reply_to_user_id_str":"333905755",
   "in_reply_to_screen_name":"waddehawk",
   "user":{"id":95310018,"id_str":"95310018",
   "name":"DBS Bank","screen_name":"dbsbank","location":"Singapore",
   "description":"The DBS official channel, we're here Mon-Fri, 9am-6pm. Otherwise, call us at 18001111111 or              contact us via www.dbs.com\/contact",
   "url":"http:             \/\/www.dbs.com","protected":false,
  "followers_count":1350,"friends_count":173,"listed_count":58,
  "created_at":"Tue Dec 08 00:07:04 +0000            2009","favourites_count":0,"utc_offset":28800,
    "time_zone":"Singapore","geo_enabled":false,
    "verified":false,"statuses_count":306,"lang":"en",
  "contributors_enabled":false,"is_translator":false,
  "profile_background_color":"CC0000",
  "profile_background_image_url":"http:\/\/a0.twimg.com\/profile_background_images\/125391568\/twitter_bg.gif",
  "profile_background_image_url_https":
    "https:\/\/si0.twimg.com\/profile_background_images\/125391568\/twitter_bg.gif",
  "profile_background_tile":false,
  "profile_image_url":"http:\/\/a0.twimg.com\/profile_images           \/1051424405\/dbslogo_e2_4c_r_normal.gif",
  "retweeted":false}]

我一直在尝试的不同代码尝试:

        Dim stringSplitter() As String = {"{"}

   ' split the f ile content based on the closing entry tag
         sampleResults = Nothing
    Try
        sampleResults = 
         post.Split(stringSplitter, StringSplitOptions.RemoveEmptyEntries)

        for each entry in sampleResults           

        Dim jreader2 As JsonTextReader = New JsonTextReader(New StringReader(entry))

        entry = "{ " & entry & "}"

        Dim js As New JavaScriptSerializer


        Dim jrobj As Object = js.DeserializeObject(entry)
        For Each crap As Object In CType(jrobj, Array)
            Console.WriteLine(crap("id"))
        Next

     ' Or try

        Dim jobj As JObject = JObject.Parse(entry)
     'Or try

        dim jarr as Jarray = JArray.Parse(jarr)

        Dim skipFlag As Boolean = False

        Dim token As JToken = JObject.Parse(entry)
        statid = token.SelectToken("id")
        searchTerm = token.SelectToken("matching_rules")



        Dim results As List(Of JToken) = jobj.Children().ToList

但我得到的错误是 JsonToken EndArray is not valid for closing jsonType Object

4

0 回答 0