当前位置: 首页>>代码示例>>C#>>正文


C# JsonValue.GetValueOrDefault方法代码示例

本文整理汇总了C#中JsonValue.GetValueOrDefault方法的典型用法代码示例。如果您正苦于以下问题:C# JsonValue.GetValueOrDefault方法的具体用法?C# JsonValue.GetValueOrDefault怎么用?C# JsonValue.GetValueOrDefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JsonValue的用法示例。


在下文中一共展示了JsonValue.GetValueOrDefault方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SearchResults

        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;
        }
开发者ID:javaday,项目名称:Spring.Social.oDesk,代码行数:32,代码来源:SearchResultsDeserializer.cs

示例2: Deserialize

        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;
        }
开发者ID:pkdevbox,项目名称:spring-net-social-linkedin,代码行数:10,代码来源:PaginatedResultDeserializer.cs

示例3: Deserialize

        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;
        }
开发者ID:VRDate,项目名称:spring-net-social-twitter,代码行数:53,代码来源:TweetDeserializer.cs

示例4: DeserializeLinkedInDate

 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;
 }
开发者ID:pkdevbox,项目名称:spring-net-social-linkedin,代码行数:13,代码来源:LinkedInFullProfileDeserializer.cs

示例5: Deserialize

        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;
        }
开发者ID:pkdevbox,项目名称:spring-net-social-linkedin,代码行数:34,代码来源:LinkedInFullProfileDeserializer.cs

示例6: Deserialize

        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;
        }
开发者ID:pkdevbox,项目名称:spring-net-social-linkedin,代码行数:16,代码来源:PostDeserializer.cs

示例7: Deserialize

        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;
        }
开发者ID:pkdevbox,项目名称:spring-net-social-linkedin,代码行数:21,代码来源:GroupDeserializer.cs

示例8: Deserialize

        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;
        }
开发者ID:pkdevbox,项目名称:spring-net-social-linkedin,代码行数:17,代码来源:LinkedInProfileDeserializer.cs

示例9: DeserializeYears

 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;
 }
开发者ID:pkdevbox,项目名称:spring-net-social-linkedin,代码行数:12,代码来源:LinkedInFullProfileDeserializer.cs

示例10: DeserializeProficiency

 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;
 }
开发者ID:pkdevbox,项目名称:spring-net-social-linkedin,代码行数:12,代码来源:LinkedInFullProfileDeserializer.cs

示例11: DeserializeCompany

 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;
 }
开发者ID:pkdevbox,项目名称:spring-net-social-linkedin,代码行数:16,代码来源:LinkedInFullProfileDeserializer.cs

示例12: ExtractAccessGrant

 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);
 }
开发者ID:huaminglee,项目名称:myyyyshop,代码行数:15,代码来源:OAuth2Template.cs

示例13: Deserialize

        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;
        }
开发者ID:javaday,项目名称:Spring.Social.oDesk,代码行数:32,代码来源:JobDeserializer.cs

示例14: DeserializeMembershipState

 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;
 }
开发者ID:pkdevbox,项目名称:spring-net-social-linkedin,代码行数:19,代码来源:GroupMembershipsDeserializer.cs

示例15: DeserializeGroup

 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;
 }
开发者ID:pkdevbox,项目名称:spring-net-social-linkedin,代码行数:10,代码来源:GroupMembershipsDeserializer.cs


注:本文中的JsonValue.GetValueOrDefault方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。