public Status(JsonElement status) { if (status.IsNull()) { return; } status.TryGetProperty("retweeted_status", out JsonElement retweetedStatus); RetweetedStatus = new Status(retweetedStatus); Retweeted = !retweetedStatus.IsNull(); Source = status.GetString("source"); InReplyToScreenName = status.GetString("in_reply_to_screen_name"); PossiblySensitive = status.GetBool("possibly_sensitive"); IsQuotedStatus = status.GetBool("is_quote_status"); QuotedStatusID = status.GetUlong("quoted_status_id"); status.TryGetProperty("quoted_status", out JsonElement quotedStatusValue); QuotedStatus = new Status(quotedStatusValue); status.TryGetProperty("contributors", out JsonElement contributors); Contributors = contributors.IsNull() ? new List <Contributor>() : (from contributor in contributors.EnumerateArray() select new Contributor(contributor)) .ToList(); status.TryGetProperty("coordinates", out JsonElement coords); if (!coords.IsNull()) { coords.TryGetProperty("coordinates", out JsonElement coordsValue); Coordinates = new Coordinate(coordsValue); } else { Coordinates = new Coordinate(); } status.TryGetProperty("place", out JsonElement placeValue); Place = new Place(placeValue); RetweetCount = status.GetInt("retweet_count"); StatusID = status.GetUlong("id"); FavoriteCount = status.GetInt("favorite_count"); Favorited = status.GetBool("favorited"); InReplyToStatusID = status.GetUlong("in_reply_to_status_id"); CreatedAt = status.GetDate("created_at", DateTime.MaxValue); InReplyToUserID = status.GetUlong("in_reply_to_user_id"); Truncated = status.GetBool("truncated"); status.TryGetProperty("display_text_range", out JsonElement displayTextRange); if (!displayTextRange.IsNull()) { JsonElement[] displayTextIndices = displayTextRange.EnumerateArray().ToArray(); DisplayTextRange = new List <int> { displayTextIndices[0].GetInt32(), displayTextIndices[1].GetInt32() }; } TweetMode tweetMode; Enum.TryParse(value: status.GetString("tweet_mode"), ignoreCase: true, result: out tweetMode); TweetMode = tweetMode; Text = status.GetString("text"); FullText = status.GetString("full_text"); status.TryGetProperty("extended_tweet", out JsonElement extendedTweetValue); ExtendedTweet = new Status(extendedTweetValue); status.TryGetProperty("annotation", out JsonElement annotationValue); Annotation = new Annotation(annotationValue); status.TryGetProperty("entities", out JsonElement entitiesValue); Entities = new Entities(entitiesValue); status.TryGetProperty("extended_entities", out JsonElement extendedEntitiesValue); ExtendedEntities = new Entities(extendedEntitiesValue); status.TryGetProperty("current_user_retweet", out JsonElement currentUserRetweet); if (!currentUserRetweet.IsNull()) { CurrentUserRetweet = currentUserRetweet.GetProperty("id").GetUInt64(); } // TODO: We need a good example of a scope so we can write a test. //JsonElement scopes = status.GetProperty("scopes"); //Scopes = // scopes.IsNull() ? new Dictionary<string, string>() : // (from key in (scopes as IDictionary<string, JsonData>).Keys as List<string> // select new // { // Key = key, // Value = scopes[key].ToString() // }) // .ToDictionary( // key => key.Key, // val => val.Value); WithheldCopyright = status.GetBool("withheld_copyright"); status.TryGetProperty("withheld_in_countries", out JsonElement withheldCountries); if (withheldCountries.IsNull()) { WithheldInCountries = new List <string>(); } else { WithheldInCountries = (from country in withheldCountries.EnumerateArray() select country.GetString()) .ToList(); } WithheldScope = status.GetString("withheld_scope"); status.TryGetProperty("metadata", out JsonElement metadataValue); MetaData = new StatusMetaData(metadataValue); Lang = status.GetString("lang"); FilterLevel filterLevel; Enum.TryParse(value: status.GetString("filter_level"), ignoreCase: true, result: out filterLevel); FilterLevel = filterLevel; status.TryGetProperty("user", out JsonElement userValue); User = new User(userValue); Users = new List <ulong>(); }