Twitterizer TwittterTimeline NewtonSoft.JSON.JsonSerializationException问题

时间:2012-01-26 22:55:37

标签: c# twitterizer json.net

以下代码抛出NewtonSoft.JSON.JsonSerializationException {“反序列化对象时的意外标记:StartObject。第1行,第1884位。”}

Twitterizer版本:2.4.0.26532 NewtonSoft.Json = 4.0.7.0(使用Visual Studio中的Nu-GET加入安装)

我有什么遗漏或者没有得到的东西吗?

   class Program
    {
        static void Main(string[] _args)
        {
            Logger.Write("Calling Twitter", Constants.TWITTER_AGREGATOR_LOG_CATEGORY);

            UserTimelineOptions options = new UserTimelineOptions();
            options.ScreenName = "as_tuce2";
            TwitterResponse<TwitterStatusCollection> tweets = TwitterTimeline.UserTimeline(options);   //throws exception


            OAuthTokens tokens = new OAuthTokens();
            tokens.AccessToken = // removed...
            tokens.AccessTokenSecret = // removed...
            tokens.ConsumerKey =  // removed...
            tokens.ConsumerSecret = // removed...

            UserTimelineOptions userOptions = new UserTimelineOptions();
            userOptions.IncludeRetweets = false;
            userOptions.ScreenName = "as_tuce2";
            userOptions.UseSSL = true;
            userOptions.Count = 20;


            TwitterResponse<TwitterUser> showUserResponse = TwitterUser.Show(tokens, "as_tuce2");            //ok
            TwitterResponse<TwitterStatusCollection> timelineResponse = TwitterTimeline.UserTimeline(tokens);  //throws exception


            Console.ReadLine();
        }
    }

堆栈跟踪:

  

在d:\ Development \ Releases \ Json \ Working \ Src \ Newtonsoft.Json \ Serialization \ JsonSerializerInternalReader.cs中的Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject,JsonReader reader,JsonObjectContract contract,String id)中:第1238行      在D:\ Development \ Releases \ Json \ Working \ Src \ Newtonsoft.Json \ Serialization \ JsonSerializerInternalReader.cs中的Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateAndPopulateObject(JsonReader reader,JsonObjectContract contract,String id):第956行      在D:\ Development \ Releases \ Json \ Working \ Src \ Newtonsoft.Json \ Serialization \ JsonSerializerInternalReader.cs中的Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader,Type objectType,JsonContract contract,JsonProperty member,Object existingValue)中:第433行      在Newtonoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader,Type objectType,JsonContract contract,JsonProperty member,Object existingValue)中的d:\ Development \ Releases \ Json \ Working \ Src \ Newtonsoft.Json \ Serialization \ JsonSerializerInternalReader.cs:第236行      在Newtonoft.Json.Serialization.JsonSerializerInternalReader.CreateValueNonProperty(JsonReader reader,Type objectType,JsonContract contract,JsonConverter converter)中的d:\ Development \ Releases \ Json \ Working \ Src \ Newtonsoft.Json \ Serialization \ JsonSerializerInternalReader.cs:第221行      在Newtonoft.Json.Serialization.JsonSerializerInternalReader.PopulateList(IWrappedCollection wrappedList,JsonReader reader,String reference,JsonArrayContract contract)d:\ Development \ Releases \ Json \ Working \ Src \ Newtonsoft.Json \ Serialization \ JsonSerializerInternalReader.cs:line 794      at Newtonoft.Json.Serialization.JsonSerializerInternalReader。&lt;&gt; c_ DisplayClass1。&lt; CreateAndPopulateList&gt; b _0(IList l,Boolean isTemporaryListReference)在d:\ Development \ Releases \ Json \ Working \ Src \ Newtonsoft.Json \ Serialization \ JsonSerializerInternalReader.cs:第744行      at Newtonsoft.Json.Utilities.CollectionUtils.CreateAndPopulateList(Type listType,Action 2 populateList) in d:\Development\Releases\Json\Working\Src\Newtonsoft.Json\Utilities\CollectionUtils.cs:line 233 at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateAndPopulateList(JsonReader reader, String reference, JsonArrayContract contract) in d:\Development\Releases\Json\Working\Src\Newtonsoft.Json\Serialization\JsonSerializerInternalReader.cs:line 732 at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String reference) in d:\Development\Releases\Json\Working\Src\Newtonsoft.Json\Serialization\JsonSerializerInternalReader.cs:line 495 at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue) in d:\Development\Releases\Json\Working\Src\Newtonsoft.Json\Serialization\JsonSerializerInternalReader.cs:line 238 at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueNonProperty(JsonReader reader, Type objectType, JsonContract contract, JsonConverter converter) in d:\Development\Releases\Json\Working\Src\Newtonsoft.Json\Serialization\JsonSerializerInternalReader.cs:line 221 at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType) in d:\Development\Releases\Json\Working\Src\Newtonsoft.Json\Serialization\JsonSerializerInternalReader.cs:line 117 at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType) in d:\Development\Releases\Json\Working\Src\Newtonsoft.Json\JsonSerializer.cs:line 421 at Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader reader, Type objectType) in d:\Development\Releases\Json\Working\Src\Newtonsoft.Json\JsonSerializer.cs:line 413 at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings) in d:\Development\Releases\Json\Working\Src\Newtonsoft.Json\JsonConvert.cs:line 732 at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings) in d:\Development\Releases\Json\Working\Src\Newtonsoft.Json\JsonConvert.cs:line 694 at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value) in d:\Development\Releases\Json\Working\Src\Newtonsoft.Json\JsonConvert.cs:line 651 at Twitterizer.Core.SerializationHelper 1.Deserialize(Byte [] webResponseData,DeserializationHandler deserializationHandler)      在Twitterizer.Core.TwitterCommand 1.ExecuteCommand() at Twitterizer.Core.CommandPerformer.PerformAction[T](ICommand 1命令)      在Twitterizer.TwitterTimeline.UserTimeline(OAuthTokens标记,UserTimelineOptions选项)      在Twitterizer.TwitterTimeline.UserTimeline(UserTimelineOptions选项)

1 个答案:

答案 0 :(得分:3)

感谢您发布此内容。我将不得不看看它,并弄清楚新版本的json.net发生了什么变化。

对于子孙后代,您here is the forums topic也报告了那里的错误。