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


C# JsonValue类代码示例

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


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

示例1: 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

示例2: IsValid

        public override bool IsValid(JsonSchemaDefinitions definitions, JsonValue value, JsonSchemaCallback callback)
        {
            bool succeeded = true;
            JsonObject target = value as JsonObject;

            if (target == null)
                return true;

            foreach (string property in target.GetKeys())
            {
                if (items.ContainsKey(property))
                {
                    JsonPathSegment segment = new JsonPropertySegment(property);
                    JsonSchemaCallback scope = callback.Scope(segment);
                    JsonSchemaRule rule = items[property];

                    if (rule.IsValid(definitions, target.Get(property), scope) == false)
                    {
                        callback.Add(scope);
                        succeeded = false;
                    }
                }
            }

            return succeeded;
        }
开发者ID:amacal,项目名称:jinx,代码行数:26,代码来源:JsonPropertiesRule.cs

示例3: IsValid

        public override bool IsValid(JsonSchemaDefinitions definitions, JsonValue value, JsonSchemaCallback callback)
        {
            if (rule.IsValid(definitions, value, JsonSchemaCallback.Ignore()) == false)
                return true;

            return callback.Fail(value, "The NOT condition should not be valid.");
        }
开发者ID:amacal,项目名称:jinx,代码行数:7,代码来源:JsonNotRule.cs

示例4: WriteArray

        private void WriteArray(JsonValue obj)
        {
            currentDepth++;
            if (currentDepth > MAX_DEPTH)
                throw new JsonException("Serializer encountered maximum depth of " + MAX_DEPTH);
            output.Append('[');

            bool append = false;
            foreach (JsonValue v in obj.store as List<JsonValue>)
            {
                if (append)
                    output.Append(',');

                if (v.type == JsonType.None || (v.type == JsonType.Null && serializeNulls == false))
                    append = false;
                else
                {
                    WriteValue(v);
                    append = true;
                }
            }

            currentDepth--;
            output.Append(']');
            currentDepth--;
        }
开发者ID:vietor,项目名称:JsonCsharp,代码行数:26,代码来源:JsonSerializer.cs

示例5: Deserialize

		public object Deserialize(JsonValue json, JsonMapper mapper)
		{
			Comment comment = null;
			if ( json != null && !json.IsNull )
			{
				comment = new Comment();
				comment.ID          = json.ContainsName("id"          ) ? json.GetValue<string>("id"     ) : String.Empty;
				comment.Message     = json.ContainsName("message"     ) ? json.GetValue<string>("message") : String.Empty;
				comment.CreatedTime = json.ContainsName("created_time") ? JsonUtils.ToDateTime(json.GetValue<string>("created_time"), "yyyy-MM-ddTHH:mm:ss") : DateTime.MinValue;

				comment.From        = mapper.Deserialize<Reference      >(json.GetValue("from" ));
				// 04/12/2012 Paul.  Likes is a connection object, so make sure that this is not the same likes property value. 
				// 04/15/2012 Paul.  Likes can be a number or an array. 
				JsonValue jsonLikes = json.GetValue("likes");
				if ( jsonLikes != null && !jsonLikes.IsNull )
				{
					if ( jsonLikes.IsArray )
					{
						comment.Likes       = mapper.Deserialize<List<Reference>>(jsonLikes);
						comment.LikesCount  = (comment.Likes != null) ? comment.Likes.Count : 0;
					}
					else if ( jsonLikes.IsNumber )
					{
						comment.LikesCount = jsonLikes.GetValue<int>();
					}
				}
			}
			return comment;
		}
开发者ID:kisspa,项目名称:spring-net-social-facebook,代码行数:29,代码来源:CommentDeserializer.cs

示例6: Deserialize

		public object Deserialize(JsonValue json, JsonMapper mapper)
		{
			Photo photo = null;
			if ( json != null && !json.IsNull )
			{
				photo = new Photo();
				photo.ID          = json.ContainsName("id"          ) ? json.GetValue<string>("id"      ) : String.Empty;
				photo.Name        = json.ContainsName("name"        ) ? json.GetValue<string>("name"    ) : String.Empty;
				photo.Icon        = json.ContainsName("icon"        ) ? json.GetValue<string>("icon"    ) : String.Empty;
				photo.Picture     = json.ContainsName("picture"     ) ? json.GetValue<string>("picture" ) : String.Empty;
				photo.Source      = json.ContainsName("source"      ) ? json.GetValue<string>("source"  ) : String.Empty;
				photo.Height      = json.ContainsName("height"      ) ? json.GetValue<int   >("height"  ) : 0;
				photo.Width       = json.ContainsName("width"       ) ? json.GetValue<int   >("width"   ) : 0;
				photo.Link        = json.ContainsName("link"        ) ? json.GetValue<string>("link"    ) : String.Empty;
				photo.Position    = json.ContainsName("position"    ) ? json.GetValue<int   >("position") : 0;
				photo.CreatedTime = json.ContainsName("created_time") ? JsonUtils.ToDateTime(json.GetValue<string>("created_time"), "yyyy-MM-ddTHH:mm:ss") : DateTime.MinValue;
				photo.UpdatedTime = json.ContainsName("updated_time") ? JsonUtils.ToDateTime(json.GetValue<string>("updated_time"), "yyyy-MM-ddTHH:mm:ss") : DateTime.MinValue;
				
				photo.From        = mapper.Deserialize<Reference>(json.GetValue("from" ));
				photo.Place       = mapper.Deserialize<Page     >(json.GetValue("place"));
				photo.Tags        = mapper.Deserialize<List<Tag>>(json.GetValue("tags" ));
				photo.Images      = mapper.Deserialize<List<Photo.Image>>(json.GetValue("images"));
				if ( photo.Images != null )
				{
					int i = 0;
					if ( photo.Images.Count >= 5 ) photo.OversizedImage = photo.Images[i++];
					if ( photo.Images.Count >= 1 ) photo.SourceImage    = photo.Images[i++];
					if ( photo.Images.Count >= 2 ) photo.AlbumImage     = photo.Images[i++];
					if ( photo.Images.Count >= 3 ) photo.SmallImage     = photo.Images[i++];
					if ( photo.Images.Count >= 4 ) photo.TinyImage      = photo.Images[i++];
				}
			}
			return photo;
		}
开发者ID:kisspa,项目名称:spring-net-social-facebook,代码行数:34,代码来源:PhotoDeserializer.cs

示例7: ReadArray

        static JsonValue ReadArray(string json, ref int i)
        {
            i++; // Skip the '['
            SkipWhitespace(json, ref i);

            JsonValue arrayval = new JsonValue();
            arrayval.Type = JsonType.Array;

            bool expectingValue = false;
            while (json[i] != ']') {
                expectingValue = false;
                arrayval.Add(ReadValue(json, ref i));
                SkipWhitespace(json, ref i);
                if (json[i] == ',') {
                    expectingValue = true;
                    i++;
                    SkipWhitespace(json, ref i);
                } else if (json[i] != ']') {
                    throw new InvalidJsonException("Expected end array token at column " + i + "!");
                }
            }

            if (expectingValue) {
                throw new InvalidJsonException("Unexpected end array token at column " + i + "!");
            }

            i++; // Skip the ']'
            return arrayval;
        }
开发者ID:grahamboree,项目名称:voorhees,代码行数:29,代码来源:JsonReader.cs

示例8: UserMentionEntity

 public UserMentionEntity(JsonValue json) : base(json)
 {
     Id = json["id"].AsLong();
     ScreenName = json["screen_name"].AsStringOrNull();
     Name = json["name"].AsStringOrNull();
     FullText = DisplayText = "@" + ScreenName;
 }
开发者ID:karno,项目名称:Cadena,代码行数:7,代码来源:UserMentionEntity.cs

示例9: IsValid

        public override bool IsValid(JsonSchemaDefinitions definitions, JsonValue value, JsonSchemaCallback callback)
        {
            int count = 0;
            List<JsonSchemaCallback> scopes = new List<JsonSchemaCallback>();

            foreach (JsonSchemaRule rule in rules)
            {
                JsonSchemaCallback scope = callback.Scope();

                if (rule.IsValid(definitions, value, scope))
                    count++;

                if (scope.Count > 0)
                    scopes.Add(scope);

                if (count > 1)
                    break;
            }

            if (count == 1)
                return true;

            if (count > 1)
                return callback.Fail(value, $"Exactly one schema should be valid, but {count} schemas were valid.");

            foreach (JsonSchemaCallback scope in scopes)
                callback.Add(scope);

            return callback.Fail(value, "Exactly one schema should be valid, but nothing was valid.");
        }
开发者ID:amacal,项目名称:jinx,代码行数:30,代码来源:JsonOneOfRule.cs

示例10: 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

示例11: Deserialize

        public object Deserialize(JsonValue value, JsonMapper mapper)
        {
            Tweet tweet = new Tweet();

            tweet.ID = value.GetValue<long>("id");
            tweet.Text = value.GetValue<string>("text");
            JsonValue fromUserValue = value.GetValue("user");
            string dateFormat;
            if (fromUserValue != null)
            {
                tweet.FromUser = fromUserValue.GetValue<string>("screen_name");
                tweet.FromUserId = fromUserValue.GetValue<long>("id");
                tweet.ProfileImageUrl = fromUserValue.GetValue<string>("profile_image_url");
                dateFormat = TIMELINE_DATE_FORMAT;
            }
            else
            {
                tweet.FromUser = value.GetValue<string>("from_user");
                tweet.FromUserId = value.GetValue<long>("from_user_id");
                tweet.ProfileImageUrl = value.GetValue<string>("profile_image_url");
                dateFormat = SEARCH_DATE_FORMAT;
            }
            tweet.CreatedAt = JsonUtils.ToDateTime(value.GetValue<string>("created_at"), dateFormat);
            tweet.Source = value.GetValue<string>("source");
            JsonValue toUserIdValue = value.GetValue("in_reply_to_user_id");
            tweet.ToUserId = (toUserIdValue != null) ? toUserIdValue.GetValue<long?>() : null;
            JsonValue languageCodeValue = value.GetValue("iso_language_code");
            tweet.LanguageCode = (languageCodeValue != null) ? languageCodeValue.GetValue<string>() : null;
            JsonValue inReplyToStatusIdValue = value.GetValue("in_reply_to_status_id");
            tweet.InReplyToStatusId = ((inReplyToStatusIdValue != null) && !inReplyToStatusIdValue.IsNull) ? inReplyToStatusIdValue.GetValue<long?>() : null;

            return tweet;
        }
开发者ID:erijss,项目名称:spring-net-social-twitter,代码行数:33,代码来源:TweetDeserializer.cs

示例12: Deserialize

 public object Deserialize(JsonValue json, JsonMapper mapper)
 {
     SimilarPlaces similarPlaces = new SimilarPlaces(mapper.Deserialize<IList<Place>>(json));
     similarPlaces.PlacePrototype = new PlacePrototype();
     similarPlaces.PlacePrototype.CreateToken = json.GetValue("result").GetValue<string>("token");
     return similarPlaces;
 }
开发者ID:kisspa,项目名称:spring-net-social-twitter,代码行数:7,代码来源:SimilarPlacesDeserializer.cs

示例13: Deserialize

 public object Deserialize(JsonValue value, JsonMapper mapper)
 {
     IList<RateLimitStatus> limits = new List<RateLimitStatus>();
     JsonValue resourcesValue = value.GetValue("resources");
     if (resourcesValue != null)
     {
         foreach(string resourceFamily in resourcesValue.GetNames())
         {
             JsonValue resourceFamilyValue = resourcesValue.GetValue(resourceFamily);
             foreach (string resourceEndpoint in resourceFamilyValue.GetNames())
             {
                 JsonValue rateLimitValue = resourceFamilyValue.GetValue(resourceEndpoint);
                 limits.Add(new RateLimitStatus()
                     {
                         ResourceFamily = resourceFamily,
                         ResourceEndpoint = resourceEndpoint,
                         WindowLimit = rateLimitValue.GetValue<int>("limit"),
                         RemainingHits = rateLimitValue.GetValue<int>("remaining"),
                         ResetTime = FromUnixTime(rateLimitValue.GetValue<long>("reset"))
                     });
             }
         }
     }
     return limits;
 }
开发者ID:kisspa,项目名称:spring-net-social-twitter,代码行数:25,代码来源:RateLimitStatusListDeserializer.cs

示例14: GetTopLevelFeedItemsArray

 /// <summary>
 /// Gets the JSON array holding the entries of the given feed.
 /// </summary>
 /// <param name="testConfiguration">The test configuration to consider.</param>
 /// <param name="feed">The JSON value representing the feed.</param>
 /// <returns>A JSON array with the items in a feed.</returns>
 public static JsonArray GetTopLevelFeedItemsArray(WriterTestConfiguration testConfiguration, JsonValue feed)
 {
     feed = feed.Object().PropertyValue("value");
     ExceptionUtilities.CheckObjectNotNull(feed, "The specified JSON Lite payload is not wrapped in the expected \"value\": wrapper.");
     ExceptionUtilities.Assert(feed.JsonType == JsonValueType.JsonArray, "Feed contents must be an array.");
     return (JsonArray)feed;
 }
开发者ID:larsenjo,项目名称:odata.net,代码行数:13,代码来源:JsonLightWriterUtils.cs

示例15: Deserialize

 public override object Deserialize(JsonValue json, JsonMapper mapper)
 {
     JsonValue peopleJson = json.ContainsName("people") ? json.GetValue("people") : json;
     LinkedInProfiles profiles = (LinkedInProfiles)base.Deserialize(peopleJson, mapper);
     profiles.Profiles = mapper.Deserialize<IList<LinkedInProfile>>(peopleJson);
     return profiles;
 }
开发者ID:pkdevbox,项目名称:spring-net-social-linkedin,代码行数:7,代码来源:LinkedInProfilesDeserializer.cs


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