/// <summary> /// Json序列化AopObject对象 /// </summary> /// <param name="res"></param> /// <returns></returns> public string serializeAopObject(AopObject res) { PropertyInfo[] pis = res.GetType().GetProperties(); IDictionary <object, object> jo = new Dictionary <object, object>(); foreach (PropertyInfo pi in pis) { if (!pi.CanRead) { continue; } String elementName = getElementName(pi); Object value = getPiValue(res, pi); if (!String.IsNullOrEmpty(elementName)) { Object serialized = serializeValue(value); if (serialized != null) { jo[elementName] = serialized; } } } JsonSerializerSettings jsetting = new JsonSerializerSettings(); jsetting.NullValueHandling = NullValueHandling.Ignore; return(JsonConvert.SerializeObject(jo, Formatting.None, jsetting)); }
public JsonObject serializeAopObject(AopObject res) { PropertyInfo[] properties = res.GetType().GetProperties(); JsonObject jsonObject = new JsonObject(); PropertyInfo[] array = properties; foreach (PropertyInfo propertyInfo in array) { if (!propertyInfo.CanRead) { continue; } string elementName = getElementName(propertyInfo); object piValue = getPiValue(res, propertyInfo); if (!string.IsNullOrEmpty(elementName)) { object obj = serializeValue(piValue); if (obj != null) { jsonObject.Put(elementName, obj); } } } return(jsonObject); }
/// <summary> /// Json序列化AopObject对象 /// </summary> /// <param name="res"></param> /// <returns></returns> public JsonObject serializeAopObject(AopObject res) { PropertyInfo[] pis = res.GetType().GetProperties(); JsonObject jo = new JsonObject(); foreach (PropertyInfo pi in pis) { if (!pi.CanRead) { continue; } String elementName = getElementName(pi); Object value = getPiValue(res, pi); if (!String.IsNullOrEmpty(elementName)) { Object serialized = serializeValue(value); if (serialized != null) { jo.Put(elementName, serialized); } } } return(jo); }
/// <summary> /// Json序列化AopObject对象 /// </summary> /// <param name="res"></param> /// <returns></returns> public IDictionary <object, object> serializeAopObject(AopObject res) { PropertyInfo[] pis = res.GetType().GetProperties(); IDictionary <object, object> jo = new Dictionary <object, object>(); foreach (PropertyInfo pi in pis) { if (!pi.CanRead) { continue; } String elementName = getElementName(pi); Object value = getPiValue(res, pi); if (!String.IsNullOrEmpty(elementName)) { Object serialized = serializeValue(value); if (serialized != null) { jo[elementName] = serialized; } } } return(jo); }