public void IgnoreDynamicCyclicReferenceLoop() { dynamic parent = new DictionaryDynamicObject(); dynamic child = new DictionaryDynamicObject(); parent.child = child; parent.name = "parent"; child.parent = parent; child.name = "child"; var settings = new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }; var c = JsonConvertX.SerializeObject(parent, settings); Assert.AreEqual(@"{""child"":{""name"":""child""},""name"":""parent""}", c); }
public void AllowNonPublicDefaultConstructor() { var settings = new JsonSerializerSettings(); settings.ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor; var json = @"{ ""contributors"": null, ""retweeted"": false, ""text"": ""Guys SX4 diesel is launched.what are your plans?catch us at #facebook http://bit.ly/dV3H1a #auto #car #maruti #india #delhi"", ""in_reply_to_user_id_str"": null, ""retweet_count"": 0, ""geo"": null, ""id_str"": ""40678260320768000"", ""in_reply_to_status_id"": null, ""source"": ""<a href=\""http://www.tweetdeck.com\"" rel=\""nofollow\"">TweetDeck</a>"", ""created_at"": ""Thu Feb 24 07:43:47 +0000 2011"", ""place"": null, ""coordinates"": null, ""truncated"": false, ""favorited"": false, ""user"": { ""profile_background_image_url"": ""http://a1.twimg.com/profile_background_images/206944715/twitter_bg.jpg"", ""url"": ""http://bit.ly/dcFwWC"", ""screen_name"": ""marutisuzukisx4"", ""verified"": false, ""friends_count"": 45, ""description"": ""This is the Official Maruti Suzuki SX4 Twitter ID! Men are Back - mail us on social (at) sx4bymaruti (dot) com"", ""follow_request_sent"": null, ""time_zone"": ""Chennai"", ""profile_text_color"": ""333333"", ""location"": ""India"", ""notifications"": null, ""profile_sidebar_fill_color"": ""efefef"", ""id_str"": ""196143889"", ""contributors_enabled"": false, ""lang"": ""en"", ""profile_background_tile"": false, ""created_at"": ""Tue Sep 28 12:55:15 +0000 2010"", ""followers_count"": 117, ""show_all_inline_media"": true, ""listed_count"": 1, ""geo_enabled"": true, ""profile_link_color"": ""009999"", ""profile_sidebar_border_color"": ""eeeeee"", ""protected"": false, ""name"": ""Maruti Suzuki SX4"", ""statuses_count"": 637, ""following"": null, ""profile_use_background_image"": true, ""profile_image_url"": ""http://a3.twimg.com/profile_images/1170694644/Slide1_normal.JPG"", ""id"": 196143889, ""is_translator"": false, ""utc_offset"": 19800, ""favourites_count"": 0, ""profile_background_color"": ""131516"" }, ""in_reply_to_screen_name"": null, ""id"": 40678260320768000, ""in_reply_to_status_id_str"": null, ""in_reply_to_user_id"": null }"; DictionaryDynamicObject foo = JsonConvert.DeserializeObject <DictionaryDynamicObject>(json, settings); Assert.AreEqual(false, foo.Values["retweeted"]); }