假设您使用Newtonsoft.Json:
您可以使用JObject来测试是否存在属性:
JObject jObj; //initialized somewhere, perhaps in your foreachvar msgProperty = jObj.Property("msg");//check if property existsif (msgProperty != null) { var mag = msgProperty.Value;} else { //there is no "msg" property, compensate somehow.}


