object IJsonDeserializer.Deserialize(JsonValue json, JsonMapper mapper)
        {
            var results = new SearchResults();
            var userJson = json.GetValue("auth_user");
            var pagingJson = json.GetValue("paging");
            var jobsJson = json.GetValue("jobs");


            results.ServerTime = json.GetValueOrDefault<long>("server_time");
            results.ProfileAccess = json.GetValueOrDefault<string>("profile_access");

            if (userJson != null)
            {
                results.AuthUser.FirstName = userJson.GetValue<string>("first_name");
                results.AuthUser.LastName = userJson.GetValue<string>("last_name");
                results.AuthUser.Username = userJson.GetValue<string>("uid");
                results.AuthUser.Email = userJson.GetValue<string>("mail");
                results.AuthUser.TimeZone = userJson.GetValue<string>("timezone");
                results.AuthUser.TimeZoneOffset = userJson.GetValue<string>("timezone_offset");
            }

            if (pagingJson != null)
            {
                results.Paging.Count = pagingJson.GetValue<int>("count");
                results.Paging.Offset = pagingJson.GetValue<int>("offset");
                results.Paging.Total = pagingJson.GetValue<int>("total");
            }

            results.Jobs = mapper.Deserialize<List<Job>>(jobsJson);

            return results;
        }
        public virtual object Deserialize(JsonValue json, JsonMapper mapper)
        {
            PaginatedResult paginatedResult = this.CreatePaginatedResult();

            paginatedResult.Total = json.GetValue<int>("_total");
            paginatedResult.Start = json.GetValueOrDefault<int>("_start", 0);
            paginatedResult.Count = json.GetValueOrDefault<int>("_count", paginatedResult.Total);

            return paginatedResult;
        }
        public virtual object Deserialize(JsonValue json, JsonMapper mapper)
        {
            PaginatedResult paginatedResult = this.CreatePaginatedResult();

            paginatedResult.Total = json.GetValue <int>("_total");
            paginatedResult.Start = json.GetValueOrDefault <int>("_start", 0);
            paginatedResult.Count = json.GetValueOrDefault <int>("_count", paginatedResult.Total);

            return(paginatedResult);
        }
        private static Group DeserializeGroup(JsonValue json)
        {
            var group = new Group();

            if (json != null)
            {
                group.ID   = json.GetValueOrDefault <int>("id");
                group.Name = json.GetValueOrDefault <string>("name");
            }
            return(group);
        }
        private AccessGrant ExtractAccessGrant(JsonValue response)
        {
            string accessToken  = response.GetValue <string>("access_token");
            string scope        = response.GetValueOrDefault <string>("scope");
            string refreshToken = response.GetValueOrDefault <string>("refresh_token");
            int?   expiresIn    = null;

            try { expiresIn = response.GetValueOrDefault <int?>("expires_in"); } catch (JsonException) { }

            return(this.CreateAccessGrant(accessToken, scope, refreshToken, expiresIn, response));
        }
Example #6
0
 private static Years DeserializeYears(JsonValue json)
 {
     if (json != null)
     {
         return(new Years()
         {
             ID = json.GetValueOrDefault <int>("id"),
             Name = json.GetValueOrDefault <string>("name", String.Empty)
         });
     }
     return(null);
 }
        public object Deserialize(JsonValue value, JsonMapper mapper)
        {
            Tweet tweet = new Tweet();

            tweet.ID = value.GetValue<long>("id");
            tweet.Text = value.GetValue<string>("text");
            tweet.CreatedAt = JsonUtils.ToDateTime(value.GetValueOrDefault<string>("created_at"), TWEET_DATE_FORMAT);
            JsonValue userValue = value.GetValue("user");
            if (userValue != null && userValue.IsObject)
            {
                tweet.User = mapper.Deserialize<TwitterProfile>(userValue);
                tweet.FromUser = tweet.User.ScreenName;
                tweet.FromUserId = tweet.User.ID;
                tweet.ProfileImageUrl = tweet.User.ProfileImageUrl;
            }
            tweet.ToUserId = value.GetValueOrDefault<long?>("in_reply_to_user_id");
            tweet.InReplyToUserId = value.GetValueOrDefault<long?>("in_reply_to_user_id");
            tweet.InReplyToUserScreenName = value.GetValueOrDefault<string>("in_reply_to_screen_name");
            tweet.InReplyToStatusId = value.GetValueOrDefault<long?>("in_reply_to_status_id");
            tweet.Source = value.GetValueOrDefault<string>("source");
            JsonValue placeValue = value.GetValue("place");
            if (placeValue != null && placeValue.IsObject)
            {
                tweet.Place = mapper.Deserialize<Place>(placeValue);
            }
            tweet.LanguageCode = value.GetValueOrDefault<string>("iso_language_code");
            tweet.RetweetCount = value.GetValueOrDefault<int>("retweet_count");
            JsonValue retweetedStatusValue = value.GetValue("retweeted_status");
            if (retweetedStatusValue != null && retweetedStatusValue.IsObject)
            {
                tweet.RetweetedStatus = mapper.Deserialize<Tweet>(retweetedStatusValue);
            }
            tweet.IsRetweetedByUser = value.GetValueOrDefault<bool>("retweeted");
            tweet.IsFavoritedByUser = value.GetValueOrDefault<bool>("favorited");
            JsonValue retweetIdValue = value.GetValue("current_user_retweet");
            if (retweetIdValue != null && retweetIdValue.IsObject)
            {
                tweet.RetweetIdByUser = retweetIdValue.GetValue<long?>("id");
            }

            // Entities
            JsonValue entitiesValue = value.GetValue("entities");
            if (entitiesValue != null)
            {
                tweet.Entities = new TweetEntities();
                tweet.Entities.Hashtags = DeserializeHashtags(entitiesValue.GetValue("hashtags"));
                tweet.Entities.UserMentions = DeserializeUserMentions(entitiesValue.GetValue("user_mentions"));
                tweet.Entities.Urls = DeserializeUrls(entitiesValue.GetValue("urls"));
                tweet.Entities.Media = DeserializeMedia(entitiesValue.GetValue("media"));
            }

            return tweet;
        }
Example #8
0
 private static Proficiency DeserializeProficiency(JsonValue json)
 {
     if (json != null)
     {
         return(new Proficiency()
         {
             Level = json.GetValueOrDefault <string>("level", String.Empty),
             Name = json.GetValueOrDefault <string>("name", String.Empty)
         });
     }
     return(null);
 }
Example #9
0
 private static LinkedInDate DeserializeLinkedInDate(JsonValue json)
 {
     if (json != null)
     {
         return(new LinkedInDate()
         {
             Year = json.GetValueOrDefault <int?>("year"),
             Month = json.GetValueOrDefault <int?>("month"),
             Day = json.GetValueOrDefault <int?>("day")
         });
     }
     return(null);
 }
 private static LinkedInDate DeserializeLinkedInDate(JsonValue json)
 {
     if (json != null)
     {
         return new LinkedInDate()
         {
             Year = json.GetValueOrDefault<int?>("year"),
             Month = json.GetValueOrDefault<int?>("month"),
             Day = json.GetValueOrDefault<int?>("day")
         };
     }
     return null;
 }
        public override object Deserialize(JsonValue json, JsonMapper mapper)
        {
            LinkedInFullProfile profile = (LinkedInFullProfile)base.Deserialize(json, mapper);

            profile.Associations = json.GetValueOrDefault<string>("associations", String.Empty);
            profile.BirthDate = DeserializeLinkedInDate(json.GetValue("dateOfBirth"));
            profile.ConnectionsCount = json.GetValue<int>("numConnections");
            profile.Distance = json.GetValue<int>("distance");
            profile.Educations = DeserializeEducations(json.GetValue("educations"));
            profile.Email = json.GetValueOrDefault<string>("emailAddress");
            profile.Honors = json.GetValueOrDefault<string>("honors", String.Empty);
            profile.ImAccounts = DeserializeImAccounts(json.GetValue("imAccounts"));
            profile.Interests = json.GetValueOrDefault<string>("interests", String.Empty);
            profile.IsConnectionsCountCapped = json.GetValue<bool>("numConnectionsCapped");
            JsonValue locationJson = json.GetValue("location");
            profile.CountryCode = locationJson.GetValue("country").GetValue<string>("code");
            profile.Location = locationJson.GetValueOrDefault<string>("name", String.Empty);
            profile.MainAddress = json.GetValueOrDefault<string>("mainAddress", String.Empty);
            profile.PhoneNumbers = DeserializePhoneNumbers(json.GetValue("phoneNumbers"));
            profile.Positions = DeserializePositions(json.GetValue("positions"));
            profile.ProposalComments = json.GetValueOrDefault<string>("proposalComments", String.Empty);
            profile.Recommendations = DeserializeRecommendations(json.GetValue("recommendationsReceived"), mapper);
            profile.RecommendersCount = json.GetValueOrDefault<int?>("numRecommenders");
            profile.Specialties = json.GetValueOrDefault<string>("specialties", String.Empty);
            profile.TwitterAccounts = DeserializeTwitterAccounts(json.GetValue("twitterAccounts"));
            profile.UrlResources = DeserializeUrlResources(json.GetValue("memberUrlResources"));
            profile.Certifications = DeserializeCertifications(json.GetValue("certifications"));
            profile.Skills = DeserializeSkills(json.GetValue("skills"));
            profile.Publications = DeserializePublications(json.GetValue("publications"));         
            profile.Courses = DeserializeCourses(json.GetValue("courses"));
            profile.Languages = DeserializeLanguages(json.GetValue("languages"));

            return profile;
        }
Example #12
0
        public override object Deserialize(JsonValue json, JsonMapper mapper)
        {
            LinkedInFullProfile profile = (LinkedInFullProfile)base.Deserialize(json, mapper);

            profile.Associations             = json.GetValueOrDefault <string>("associations", String.Empty);
            profile.BirthDate                = DeserializeLinkedInDate(json.GetValue("dateOfBirth"));
            profile.ConnectionsCount         = json.GetValue <int>("numConnections");
            profile.Distance                 = json.GetValue <int>("distance");
            profile.Educations               = DeserializeEducations(json.GetValue("educations"));
            profile.Email                    = json.GetValueOrDefault <string>("emailAddress");
            profile.Honors                   = json.GetValueOrDefault <string>("honors", String.Empty);
            profile.ImAccounts               = DeserializeImAccounts(json.GetValue("imAccounts"));
            profile.Interests                = json.GetValueOrDefault <string>("interests", String.Empty);
            profile.IsConnectionsCountCapped = json.GetValue <bool>("numConnectionsCapped");
            JsonValue locationJson = json.GetValue("location");

            profile.CountryCode       = locationJson.GetValue("country").GetValue <string>("code");
            profile.Location          = locationJson.GetValueOrDefault <string>("name", String.Empty);
            profile.MainAddress       = json.GetValueOrDefault <string>("mainAddress", String.Empty);
            profile.PhoneNumbers      = DeserializePhoneNumbers(json.GetValue("phoneNumbers"));
            profile.Positions         = DeserializePositions(json.GetValue("positions"));
            profile.ProposalComments  = json.GetValueOrDefault <string>("proposalComments", String.Empty);
            profile.Recommendations   = DeserializeRecommendations(json.GetValue("recommendationsReceived"), mapper);
            profile.RecommendersCount = json.GetValueOrDefault <int?>("numRecommenders");
            profile.Specialties       = json.GetValueOrDefault <string>("specialties", String.Empty);
            profile.TwitterAccounts   = DeserializeTwitterAccounts(json.GetValue("twitterAccounts"));
            profile.UrlResources      = DeserializeUrlResources(json.GetValue("memberUrlResources"));
            profile.Certifications    = DeserializeCertifications(json.GetValue("certifications"));
            profile.Skills            = DeserializeSkills(json.GetValue("skills"));
            profile.Publications      = DeserializePublications(json.GetValue("publications"));
            profile.Courses           = DeserializeCourses(json.GetValue("courses"));
            profile.Languages         = DeserializeLanguages(json.GetValue("languages"));

            return(profile);
        }
        public virtual object Deserialize(JsonValue json, JsonMapper mapper)
        {
            var post = CreatePost();

            post.ID = json.GetValue<string>("id");
            post.Creator = mapper.Deserialize<LinkedInProfile>(json.GetValue("creator"));
            post.Title = json.GetValueOrDefault<string>("title", String.Empty);
            post.Type = DeserializePostType(json.GetValue("type"));
            //TODO post.Attachment = DeserializeAttachment(json.GetValue("attachment")); 
            post.CreationTimestamp = DeserializeTimeStamp.Deserialize(json.GetValue("creationTimestamp"));
            post.Likes = mapper.Deserialize<IList<LinkedInProfile>>(json.GetValue("likes"));
            //TODO RelationToViewer = DeserializePostRelation(json.GetValue("relation-to-viewer"));
            post.Summary = json.GetValueOrDefault<string>("summary", String.Empty);

            return post;
        }
        private static MembershipState DeserializeMembershipState(JsonValue json)
        {
            if (json != null)
            {
                var code = json.GetValueOrDefault <string>("code");
                switch (code.ToLowerInvariant())
                {
                case "awaiting-confirmation": return(MembershipState.AwaitingConfirmation);

                case "awaiting-parent-group-confirmation": return(MembershipState.AwaitingParentGroupConfirmation);

                case "blocked": return(MembershipState.Blocked);

                case "manager": return(MembershipState.Manager);

                case "member": return(MembershipState.Member);

                case "moderator": return(MembershipState.Moderator);

                case "non-member": return(MembershipState.NonMember);

                case "owner": return(MembershipState.Owner);
                }
            }
            return(MembershipState.NonMember);
        }
Example #15
0
        public virtual object Deserialize(JsonValue json, JsonMapper mapper)
        {
            var post = CreatePost();

            post.ID      = json.GetValue <string>("id");
            post.Creator = mapper.Deserialize <LinkedInProfile>(json.GetValue("creator"));
            post.Title   = json.GetValueOrDefault <string>("title", String.Empty);
            post.Type    = DeserializePostType(json.GetValue("type"));
            //TODO post.Attachment = DeserializeAttachment(json.GetValue("attachment"));
            post.CreationTimestamp = DeserializeTimeStamp.Deserialize(json.GetValue("creationTimestamp"));
            post.Likes             = mapper.Deserialize <IList <LinkedInProfile> >(json.GetValue("likes"));
            //TODO RelationToViewer = DeserializePostRelation(json.GetValue("relation-to-viewer"));
            post.Summary = json.GetValueOrDefault <string>("summary", String.Empty);

            return(post);
        }
        public virtual object Deserialize(JsonValue json, JsonMapper mapper)
        {
            Group group = CreateGroup();

            group.AllowMemberInvites = json.GetValueOrDefault<bool>("allowMemberInvites");
            group.Category = DeserializeGroupCategory(json.GetValue("category"));
            group.CountsByCategory = DeserializeCountsByCategory(json.GetValue("countsByCategory"));
            group.Description = json.GetValueOrDefault<string>("description");
            group.ID = json.GetValue<int>("id");
            group.IsOpenToNonMembers = json.GetValueOrDefault<bool>("isOpenToNonMembers");
            group.LargeLogoUrl = json.GetValueOrDefault<string>("largeLogoUrl");
            group.Locale = json.GetValueOrDefault<string>("locale");
            group.Name = json.GetValueOrDefault<string>("name");
            group.Posts = mapper.Deserialize<GroupPosts>(json.GetValue("posts"));
            group.ShortDescription = json.GetValueOrDefault<string>("shortDescription");
            group.SiteGroupUrl = json.GetValueOrDefault<string>("siteGroupUrl");
            group.SmallLogoUrl = json.GetValueOrDefault<string>("smallLogoUrl");
            group.WebsiteUrl = json.GetValueOrDefault<string>("websiteUrl");

            return group;
        }
Example #17
0
        public virtual object Deserialize(JsonValue json, JsonMapper mapper)
        {
            Group group = CreateGroup();

            group.AllowMemberInvites = json.GetValueOrDefault <bool>("allowMemberInvites");
            group.Category           = DeserializeGroupCategory(json.GetValue("category"));
            group.CountsByCategory   = DeserializeCountsByCategory(json.GetValue("countsByCategory"));
            group.Description        = json.GetValueOrDefault <string>("description");
            group.ID = json.GetValue <int>("id");
            group.IsOpenToNonMembers = json.GetValueOrDefault <bool>("isOpenToNonMembers");
            group.LargeLogoUrl       = json.GetValueOrDefault <string>("largeLogoUrl");
            group.Locale             = json.GetValueOrDefault <string>("locale");
            group.Name             = json.GetValueOrDefault <string>("name");
            group.Posts            = mapper.Deserialize <GroupPosts>(json.GetValue("posts"));
            group.ShortDescription = json.GetValueOrDefault <string>("shortDescription");
            group.SiteGroupUrl     = json.GetValueOrDefault <string>("siteGroupUrl");
            group.SmallLogoUrl     = json.GetValueOrDefault <string>("smallLogoUrl");
            group.WebsiteUrl       = json.GetValueOrDefault <string>("websiteUrl");

            return(group);
        }
        public virtual object Deserialize(JsonValue json, JsonMapper mapper)
        {
            LinkedInProfile profile = CreateLinkedInProfile();

            profile.ID = json.GetValueOrDefault<string>("id"); //sometimes id is null (on posts)
            profile.FirstName = json.GetValueOrDefault<string>("firstName", String.Empty);
            profile.LastName = json.GetValueOrDefault<string>("lastName", String.Empty);
            profile.Headline = json.GetValueOrDefault<string>("headline", String.Empty);
            profile.Industry = json.GetValueOrDefault<string>("industry", String.Empty);
            profile.PictureUrl = json.GetValueOrDefault<string>("pictureUrl");
            profile.Summary = json.GetValueOrDefault<string>("summary", String.Empty);
            profile.PublicProfileUrl = json.GetValueOrDefault<string>("publicProfileUrl");
            profile.StandardProfileUrl = GetSiteStandardProfileUrl(json);
            profile.AuthToken = GetAuthToken(json);

            return profile;
        }
        public virtual object Deserialize(JsonValue json, JsonMapper mapper)
        {
            LinkedInProfile profile = CreateLinkedInProfile();

            profile.ID                 = json.GetValueOrDefault <string>("id"); //sometimes id is null (on posts)
            profile.FirstName          = json.GetValueOrDefault <string>("firstName", String.Empty);
            profile.LastName           = json.GetValueOrDefault <string>("lastName", String.Empty);
            profile.Headline           = json.GetValueOrDefault <string>("headline", String.Empty);
            profile.Industry           = json.GetValueOrDefault <string>("industry", String.Empty);
            profile.PictureUrl         = json.GetValueOrDefault <string>("pictureUrl");
            profile.Summary            = json.GetValueOrDefault <string>("summary", String.Empty);
            profile.PublicProfileUrl   = json.GetValueOrDefault <string>("publicProfileUrl");
            profile.StandardProfileUrl = GetSiteStandardProfileUrl(json);
            profile.AuthToken          = GetAuthToken(json);

            return(profile);
        }
Example #20
0
        public object Deserialize(JsonValue json, JsonMapper mapper)
        {
            Place place = new Place();

            place.ID       = json.GetValue <string>("id");
            place.Name     = json.GetValue <string>("name");
            place.FullName = json.GetValue <string>("full_name");
            JsonValue attributesValue = json.GetValue("attributes");

            if (attributesValue != null)
            {
                place.StreetAddress = attributesValue.GetValueOrDefault <string>("street_address");
            }
            place.Country     = json.GetValue <string>("country");
            place.CountryCode = json.GetValue <string>("country_code");
            place.PlaceType   = (PlaceType)Enum.Parse(typeof(PlaceType), json.GetValue <string>("place_type"), true);
            return(place);
        }
Example #21
0
 private static Company DeserializeCompany(JsonValue json)
 {
     if (json != null)
     {
         return(new Company()
         {
             ID = json.GetValueOrDefault <int>("id"),
             Name = json.GetValueOrDefault <string>("name", String.Empty),
             Industry = json.GetValueOrDefault <string>("industry", String.Empty),
             Size = json.GetValueOrDefault <string>("size", String.Empty),
             Type = json.GetValueOrDefault <string>("type", String.Empty),
             Ticker = json.GetValueOrDefault <string>("ticker", String.Empty)
         });
     }
     return(null);
 }
 private static Company DeserializeCompany(JsonValue json)
 {
     if (json != null)
     {
         return new Company()
         {
             ID = json.GetValueOrDefault<int>("id"),
             Name = json.GetValueOrDefault<string>("name", String.Empty),
             Industry = json.GetValueOrDefault<string>("industry", String.Empty),
             Size = json.GetValueOrDefault<string>("size", String.Empty),
             Type = json.GetValueOrDefault<string>("type", String.Empty),
             Ticker = json.GetValueOrDefault<string>("ticker", String.Empty)
         };
     }
     return null;
 }
Example #23
0
 private AccessGrant ExtractAccessGrant(JsonValue response)
 {
     string accessToken = response.GetValue<string>("access_token");
     string valueOrDefault = response.GetValueOrDefault<string>("scope");
     string refreshToken = response.GetValueOrDefault<string>("refresh_token");
     int? expiresIn = null;
     try
     {
         expiresIn = response.GetValueOrDefault<int?>("expires_in");
     }
     catch (JsonException)
     {
     }
     return this.CreateAccessGrant(accessToken, valueOrDefault, refreshToken, expiresIn, response);
 }
        public object Deserialize(JsonValue value, JsonMapper mapper)
        {
            Tweet tweet = new Tweet();

            tweet.ID        = value.GetValue <long>("id");
            tweet.Text      = value.GetValue <string>("text");
            tweet.CreatedAt = JsonUtils.ToDateTime(value.GetValueOrDefault <string>("created_at"), TWEET_DATE_FORMAT);
            JsonValue userValue = value.GetValue("user");

            if (userValue != null && userValue.IsObject)
            {
                tweet.User            = mapper.Deserialize <TwitterProfile>(userValue);
                tweet.FromUser        = tweet.User.ScreenName;
                tweet.FromUserId      = tweet.User.ID;
                tweet.ProfileImageUrl = tweet.User.ProfileImageUrl;
            }
            tweet.ToUserId                = value.GetValueOrDefault <long?>("in_reply_to_user_id");
            tweet.InReplyToUserId         = value.GetValueOrDefault <long?>("in_reply_to_user_id");
            tweet.InReplyToUserScreenName = value.GetValueOrDefault <string>("in_reply_to_screen_name");
            tweet.InReplyToStatusId       = value.GetValueOrDefault <long?>("in_reply_to_status_id");
            tweet.Source = value.GetValueOrDefault <string>("source");
            JsonValue placeValue = value.GetValue("place");

            if (placeValue != null && placeValue.IsObject)
            {
                tweet.Place = mapper.Deserialize <Place>(placeValue);
            }
            tweet.LanguageCode  = value.GetValueOrDefault <string>("iso_language_code");
            tweet.FavoriteCount = value.GetValueOrDefault <int>("favorite_count");
            tweet.RetweetCount  = value.GetValueOrDefault <int>("retweet_count");
            JsonValue retweetedStatusValue = value.GetValue("retweeted_status");

            if (retweetedStatusValue != null && retweetedStatusValue.IsObject)
            {
                tweet.RetweetedStatus = mapper.Deserialize <Tweet>(retweetedStatusValue);
            }
            tweet.IsRetweetedByUser = value.GetValueOrDefault <bool>("retweeted");
            tweet.IsFavoritedByUser = value.GetValueOrDefault <bool>("favorited");
            JsonValue retweetIdValue = value.GetValue("current_user_retweet");

            if (retweetIdValue != null && retweetIdValue.IsObject)
            {
                tweet.RetweetIdByUser = retweetIdValue.GetValue <long?>("id");
            }

            // Entities
            JsonValue entitiesValue = value.GetValue("entities");

            if (entitiesValue != null)
            {
                tweet.Entities              = new TweetEntities();
                tweet.Entities.Hashtags     = DeserializeHashtags(entitiesValue.GetValue("hashtags"));
                tweet.Entities.UserMentions = DeserializeUserMentions(entitiesValue.GetValue("user_mentions"));
                tweet.Entities.Urls         = DeserializeUrls(entitiesValue.GetValue("urls"));
                tweet.Entities.Media        = DeserializeMedia(entitiesValue.GetValue("media"));
            }

            return(tweet);
        }
 private static Proficiency DeserializeProficiency(JsonValue json)
 {
     if (json != null)
     {
         return new Proficiency()
         {
             Level = json.GetValueOrDefault<string>("level", String.Empty),
             Name = json.GetValueOrDefault<string>("name", String.Empty)
         };
     }
     return null;
 }
        public object Deserialize(JsonValue json, JsonMapper mapper)
        {
            var job = new Job();

            var clientJson = json.GetValue("client");

            job.Id = json.GetValueOrDefault<string>("id", "");
            job.Title = json.GetValueOrDefault<string>("title", "");
            job.Snippet = json.GetValueOrDefault<string>("snippet", "");
            job.Skills = deserializeSkills(json.GetValues("skills"));
            job.Category = json.GetValueOrDefault<string>("category", "");
            job.Subcategory = json.GetValueOrDefault<string>("subcategory", "");
            job.JobType = json.GetValueOrDefault<string>("job_type", "");
            job.Duration = json.GetValueOrDefault<string>("duration", "");
            job.Budget = json.GetValueOrDefault<string>("budget", "");
            job.Workload = json.GetValueOrDefault<string>("workload", "");
            job.Status = json.GetValueOrDefault<string>("job_status", "");
            job.Url = json.GetValueOrDefault<string>("url", "");
            job.DateCreated = json.GetValueOrDefault<DateTime>("date_created", DateTime.MinValue);

            if (clientJson != null)
            {
                job.Client.Country = clientJson.GetValueOrDefault<string>("country", "");
                job.Client.FeedbackRating = clientJson.GetValueOrDefault<float>("feedback", 0);
                job.Client.ReviewCount = clientJson.GetValueOrDefault<int>("reviews_count", 0);
                job.Client.JobCount = clientJson.GetValueOrDefault<int>("jobs_posted", 0);
                job.Client.HireCount = clientJson.GetValueOrDefault<int>("past_hires", 0);
                job.Client.PaymentVerificationStatus = clientJson.GetValueOrDefault<string>("payment_verification_status", "");
            }

            return job;
        }
 private static Years DeserializeYears(JsonValue json)
 {
     if (json != null)
     {
         return new Years()
         {
             ID = json.GetValueOrDefault<int>("id"),
             Name = json.GetValueOrDefault<string>("name", String.Empty)
         };
     }
     return null;
 }
 private static Group DeserializeGroup(JsonValue json)
 {
     var group = new Group();
     if (json != null)
     {
         group.ID = json.GetValueOrDefault<int>("id");
         group.Name = json.GetValueOrDefault<string>("name");
     }
     return group;
 }
Example #29
0
 public object Deserialize(JsonValue value, JsonMapper mapper)
 {
     return(new TwitterProfile()
     {
         ID = value.GetValue <long>("id"),
         ScreenName = value.GetValueOrDefault <string>("screen_name"),
         Name = value.GetValueOrDefault <string>("name"),
         Url = value.GetValueOrDefault <string>("url"),
         ProfileImageUrl = value.GetValueOrDefault <string>("profile_image_url"),
         Description = value.GetValueOrDefault <string>("description", String.Empty),
         Location = value.GetValueOrDefault <string>("location", String.Empty),
         CreatedDate = JsonUtils.ToDateTime(value.GetValueOrDefault <string>("created_at"), DATE_FORMAT),
         IsNotificationsEnabled = value.GetValueOrDefault <bool>("notifications"),
         Language = value.GetValueOrDefault <string>("lang"),
         StatusesCount = value.GetValueOrDefault <int>("statuses_count"),
         FriendsCount = value.GetValueOrDefault <int>("friends_count"),
         FollowersCount = value.GetValueOrDefault <int>("followers_count"),
         FavoritesCount = value.GetValueOrDefault <int>("favourites_count"),
         ListedCount = value.GetValueOrDefault <int>("listed_count"),
         IsFollowing = value.GetValueOrDefault <bool>("following"),
         IsFollowRequestSent = value.GetValueOrDefault <bool>("follow_request_sent"),
         IsProtected = value.GetValueOrDefault <bool>("protected"),
         IsVerified = value.GetValueOrDefault <bool>("verified"),
         IsGeoEnabled = value.GetValueOrDefault <bool>("geo_enabled"),
         IsContributorsEnabled = value.GetValueOrDefault <bool>("contributors_enabled"),
         IsTranslator = value.GetValueOrDefault <bool>("is_translator"),
         TimeZone = value.GetValueOrDefault <string>("time_zone"),
         UtcOffset = value.GetValueOrDefault <int>("utc_offset"),
         UseBackgroundImage = value.GetValueOrDefault <bool>("profile_use_background_image"),
         SidebarBorderColor = value.GetValueOrDefault <string>("profile_sidebar_border_color"),
         SidebarFillColor = value.GetValueOrDefault <string>("profile_sidebar_fill_color"),
         BackgroundColor = value.GetValueOrDefault <string>("profile_background_color"),
         BackgroundImageUrl = value.GetValueOrDefault <string>("profile_background_image_url"),
         IsBackgroundImageTiled = value.GetValueOrDefault <bool>("profile_background_tile"),
         TextColor = value.GetValueOrDefault <string>("profile_text_color"),
         LinkColor = value.GetValueOrDefault <string>("profile_link_color"),
         ShowAllInlineMedia = value.GetValueOrDefault <bool>("show_all_inline_media"),
     });
 }
 private static MembershipState DeserializeMembershipState(JsonValue json)
 {
     if (json != null)
     {
         var code = json.GetValueOrDefault<string>("code");
         switch (code.ToLowerInvariant())
         {
             case "awaiting-confirmation": return MembershipState.AwaitingConfirmation;
             case "awaiting-parent-group-confirmation": return MembershipState.AwaitingParentGroupConfirmation;
             case "blocked": return MembershipState.Blocked;
             case "manager": return MembershipState.Manager;
             case "member": return MembershipState.Member;
             case "moderator": return MembershipState.Moderator;
             case "non-member": return MembershipState.NonMember;
             case "owner": return MembershipState.Owner;
         }
     }
     return MembershipState.NonMember;
 }