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


C# JsonValue.ContainsKey方法代码示例

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


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

示例1: Populate

		void Populate (JsonValue json, RootElement root, JsonValue data)
		{
			if (json.ContainsKey(Constants.Title))
				root.Caption = json[Constants.Title];
			
			JsonValue jsonRoot = null;
			try {
				jsonRoot = json[Constants.Root];
			} catch (Exception){
				Console.WriteLine("Bad JSON: could not find the root element - "+json.ToString()) ;	
				return;
			}
			
			if (json.ContainsKey(Constants.DataRoot)){
				var dataroot = json[Constants.DataRoot].CleanString();
				if (data!=null && data.ContainsKey(dataroot))
					data = data[dataroot];
			}			
			
			
			foreach (JsonObject section in jsonRoot){
				var sec = new FormSectionBuilder(this._controller).Build(section, data);
				foreach (var el in sec.Elements) {
					if (!string.IsNullOrEmpty(el.ID) && !_elements.ContainsKey(el.ID)) _elements.Add(el.ID, el);
				}
				root.Add(sec);
			}
		}
开发者ID:goneflyin,项目名称:MonoMobile.Forms,代码行数:28,代码来源:FormBindingContext.cs

示例2: Parser

 internal Parser(JsonValue json)
 {
     _sourceparser = json;
     MissingTokens = json.ContainsKey("missing_tokens")
                         ? new HashSet<string>(json["missing_tokens"].Select(x => (string) x))
                         : new HashSet<string>();
 }
开发者ID:CVertex,项目名称:bigml-csharp,代码行数:7,代码来源:Parser.cs

示例3: GetString

 public static string GetString(JsonValue obj, string key)
 {
     if (obj.ContainsKey(key))
         if (obj[key].JsonType == JsonType.String)
             return (string)obj[key];
     return null;
 }
开发者ID:josiahpeters,项目名称:CCBoise,代码行数:7,代码来源:DrupalApiParser.cs

示例4: FullQuestion

        public FullQuestion(JsonValue jsonValue, Spin spin)
        {
            this.Spin = spin;

            if (jsonValue.ContainsKey("powerup_question"))
                this.PowerupQuestion = new Question(jsonValue["powerup_question"], this);
            this.Question = new Question(jsonValue["question"], this);
        }
开发者ID:hetelek,项目名称:TriviaCrackHack,代码行数:8,代码来源:Program.cs

示例5: ContainsKey

		private static bool ContainsKey (JsonValue jsonValue, string key)
		{
			if (!jsonValue.ContainsKey (key)) {
				LogContext.Current.Log<JsonUtil> ("JsonValueString: Missing key", key);
				return false;
			} else
				return true;
		}
开发者ID:avantidesai,项目名称:EmpireCLS,代码行数:8,代码来源:JsonUtil.cs

示例6: CheckForLandmark

		public static string CheckForLandmark (JsonValue searchResult, string locationName)
		{

			string result = "";
			result = (
			    searchResult.ContainsKey ("types") ? (searchResult ["types"] as JsonArray).ToList () : new List<JsonValue> ()
			).Exists (v =>
                v == "stadium" // build this out as necessary with valid types from here https://developers.google.com/places/documentation/supported_types
			) ? locationName : "";
			return result;
		}
开发者ID:avantidesai,项目名称:EmpireCLS,代码行数:11,代码来源:AddressLookupUtils.cs

示例7: AddApp

        internal void AddApp(int appId, JsonValue app, JsonValue engines)
        {
            var matches = new List<PathMatch>();

            if (app.ContainsKey(Key))
            {
                matches.AddRange(app[Key].Select(match => new PathMatch(match.Value)));
            }

            if (app.ContainsKey("engine"))
            {
                var args = app["engine"];
                var engine = engines[(string) args["name"]];
                if (engine.ContainsKey(Key))
                {
                    matches.AddRange(engine[Key].Select(match => new PathMatch(match.Value, args)));
                }
            }

            Apps[appId] = matches;
        }
开发者ID:zr40,项目名称:steamdisksaver,代码行数:21,代码来源:Category.cs

示例8: GetQuietTime

 static QuietTime GetQuietTime(JsonValue jsonValue)
 {
     if (jsonValue.ContainsKey("quiettime"))
     {
         var quiettime = jsonValue["quiettime"];
         return new QuietTime
                    {
                        Start = quiettime.StringValue("start"),
                        End = quiettime.StringValue("end"),
                    };
     }
     return null;
 }
开发者ID:farhadbheekoo,项目名称:UrbanBlimp,代码行数:13,代码来源:GetRegistrationResponseDeSerializer.cs

示例9: DecodeLoginResponse

		public static LoginResponse DecodeLoginResponse (JsonValue json)
		{
			LoginResponse response = new LoginResponse ();

			if (json == null) {
				response.StatusCode = Response.UnknownError;
				return response;
			}

			if (json.ContainsKey (STATUS)) {
				response.StatusCode = json [STATUS];
			} else if (json.ContainsKey (EXCEPTION)) {
				response.StatusCode = json [EXCEPTION];
			}

			if (json.ContainsKey (UserInfo.SESSIONID)) {
				response.SessionId = json [UserInfo.SESSIONID];
			}

			if (json.ContainsKey (UserInfo.NAME)) {
				response.Name = json [UserInfo.NAME];
			}

			if (json.ContainsKey (UserInfo.EMAIL)) {
				response.email = json [UserInfo.EMAIL];
			}

//			if (!response.IsOk) {
//				if (json.ContainsKey (MESSAGE)) {
//					response.Message = json [MESSAGE];
//				} else if (json.ContainsKey ("msg")) {
//					response.Message = json ["msg"];
//				}
//			}

			return response;
		}
开发者ID:Gerhic,项目名称:Need2Park,代码行数:37,代码来源:Codec.cs

示例10: Session

        public Session(JsonValue json)
            : this()
        {
            Id = json["id"];
            Title = json["title"];
            Abstract = json["abstract"];
            Location = json["location"];

            var begins = json["begins"].ToString().Trim ('"').Substring (0, 19).Replace ("T", " ");
            Begins = DateTime.Parse (begins);
            if (json.ContainsKey("ends"))
            {
                var ends = json["ends"].ToString().Trim('"').Substring(0, 19).Replace("T", " ");
                Ends = DateTime.Parse(ends, System.Globalization.CultureInfo.InvariantCulture);
            }
        }
开发者ID:programfreaks,项目名称:WAC2014-Droid,代码行数:16,代码来源:Session.cs

示例11: VBUser

		public VBUser(JsonValue json) {
			DB_Communicator db = DB_Communicator.getInstance();
			this.idUser = db.convertAndInitializeToInt(db.containsKey(json, "id", DB_Communicator.JSON_TYPE_INT));
			this.name = db.convertAndInitializeToString(db.containsKey(json, "name", DB_Communicator.JSON_TYPE_STRING));
			this.email = db.convertAndInitializeToString(db.containsKey(json, "email", DB_Communicator.JSON_TYPE_STRING));
			this.state = db.convertAndInitializeToString(db.containsKey(json, "state", DB_Communicator.JSON_TYPE_STRING));
			this.setUserType(db.convertAndInitializeToString(db.containsKey(json, "userType", DB_Communicator.JSON_TYPE_STRING)));
			this.listTeamRole = new List<VBTeamrole>();
			if(json.ContainsKey("teamroles")) {
				if(json["teamroles"] is JsonObject) {
					JsonValue teamrole = json["teamroles"]["TeamRole"];
					this.listTeamRole.Add(new VBTeamrole(teamrole));
				} else {
					foreach(JsonValue teamrole in json["teamroles"]) {
						this.listTeamRole.Add(new VBTeamrole(teamrole["TeamRole"]));
					}
				} 
			}
		}
开发者ID:Tucaen,项目名称:Karlsfeld-Volleyball-App,代码行数:19,代码来源:VBUser.cs

示例12: valueOrDefault

 public static JsonValue valueOrDefault(JsonValue jsonObject, string key, string defaultValue)
 {
     // Returns jsonObject[key] if it exists. If the key doesn't exist returns defaultValue and
     // logs the anomaly into the Chronojump log.
     if (jsonObject.ContainsKey (key)) {
         return jsonObject [key];
     } else {
         LogB.Information ("JsonUtils::valueOrDefault: returning default (" + defaultValue + ") from JSON: " + jsonObject.ToString ());
         return defaultValue;
     }
 }
开发者ID:GNOME,项目名称:chronojump,代码行数:11,代码来源:json.cs

示例13: toastJson

		public void toastJson(Context context, JsonValue json, ToastLength length, string alternativeMessage) {
			Context c = (context != null) ? context : mainActivity;
			string message = (json.ContainsKey("message")) ? json["message"].ToString() : alternativeMessage;
			Toast.MakeText(c, message, length).Show();
		}
开发者ID:Tucaen,项目名称:Karlsfeld-Volleyball-App,代码行数:5,代码来源:ViewController.cs

示例14: Populate

		void Populate (JsonValue json, RootElement root, JsonValue data)
		{
			if (json.ContainsKey("title"))
				root.Caption = json["title"];
			
			JsonValue jsonRoot = null;
			try {
				jsonRoot = json["root"];
			} catch (Exception){
				Console.WriteLine("Bad JSON: could not find the root element - "+json.ToString()) ;	
				return;
			}
			
			foreach (JsonObject section in jsonRoot){
				var sec = new Section(section.s("caption"), section.s("footer"));
				
				if (section.ContainsKey("elements")){
					foreach (JsonObject elem in section["elements"]) {
						
						var dataForElement = data;
						var bindExpression = elem.s("bind");
						if (bindExpression!=null) {
							try {
								if (data!=null && data.JsonType==JsonType.Object){
									var bind = elem.s("bind");
									if (data != null && !string.IsNullOrEmpty(bind) && data.ContainsKey(bind)) {
										dataForElement = data[bind];
									}
								} else if (bindExpression.StartsWith("#")) {
									dataForElement = _controller.GetValue(bindExpression.Replace("#", "")); 	
								}
							} catch (Exception){
								Console.WriteLine("Exception when binding element " + elem.ToString());	
							}
						}
						
						_parseElement(elem, sec, dataForElement);
					}
					
				} else if (section.ContainsKey("iterate") && data != null){
					string iterationname = section["iterate"];	
					string emptyMessage = section.ContainsKey("empty") ? section["empty"].CleanString() : "Empty";
					var iterationdata = string.IsNullOrEmpty(iterationname) ? (JsonArray)data : (JsonArray)data[iterationname];
					var template = (JsonObject)section["template"];
					
					var items = iterationdata.ToList();
					if (items.Count>0) {
						foreach(JsonValue v in items){
							_parseElement(template, sec, v);
						}
					} else {
						sec.Add(new EmptyListElement(emptyMessage));
						
					}
					
				} else if (section.ContainsKey("iterateproperties") && data != null){
					string iterationname = section["iterateproperties"];	
					string emptyMessage = section.ContainsKey("empty") ? section["empty"].CleanString() : "Empty";
					
					var iterationdata = string.IsNullOrEmpty(iterationname) ? (JsonObject)data : (JsonObject)data[iterationname];
					var template = (JsonObject)section["template"];
					var items =  iterationdata.Keys;
					if (items.Count>0) {
						foreach(string v in items){
							var obj = new JsonObject();
							obj.Add(v, iterationdata[v]);
							_parseElement(template, sec, obj);
						}
					} else {
						sec.Add(new EmptyListElement(emptyMessage));
						
					}
				}
				root.Add(sec);
			}
		}
开发者ID:escoz,项目名称:MonoMobile.Forms,代码行数:76,代码来源:JsonBindingContext.cs

示例15: containsKey

		public JsonValue containsKey(JsonValue value, string key, int type) {
			JsonPrimitive nullValue = new JsonPrimitive("");
			switch(type) {
			case JSON_TYPE_INT:
				nullValue = new JsonPrimitive(0);
				break;
			case 1:
				nullValue = new JsonPrimitive("");
				break;
			case 2:
				nullValue = new JsonPrimitive(new DateTime());
				break;
			}
			if(value == null)
				return nullValue;
			return (value.ContainsKey(key)) ? value[key] : nullValue;
		}
开发者ID:Tucaen,项目名称:Karlsfeld-Volleyball-App,代码行数:17,代码来源:DB-Communicator.cs


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