public JsonSettingWrap(JsonSetting jsonSetting) { if (jsonSetting == null) { jsonSetting = new JsonSetting(); } ContractResolver = new JsonContractResolver(jsonSetting.IgnoreNulls, jsonSetting.PropertiesToIgnoreNull, jsonSetting.TypesToIgnoreNull); }
public JsonSettingWrap(JsonSetting jsonSetting) { if (jsonSetting != null) { //如果为null则不进行特殊处理 ContractResolver = new JsonContractResolver(jsonSetting.IgnoreNulls, jsonSetting.PropertiesToIgnoreNull, jsonSetting.TypesToIgnoreNull); } //else //{ // jsonSetting = new JsonSetting(); //} }
/// <summary> /// JSON 输出设置 构造函数 优先级: ignoreNulls < propertiesToIgnoreNull < typesToIgnoreNull /// </summary> /// <param name="ignoreNulls">是否忽略具有IJsonIgnoreNull接口,且为Null值的属性。如果为true,符合此条件的属性将不会出现在Json字符串中</param> /// <param name="propertiesToIgnoreNull">需要特殊忽略null值的属性名称</param> /// <param name="typesToIgnoreNull">指定类型(Class,非Interface)下的为null属性不生成到Json中</param> public JsonSettingWrap(bool ignoreNulls = false, List <string> propertiesToIgnoreNull = null, List <Type> typesToIgnoreNull = null) { ContractResolver = new JsonContractResolver(ignoreNulls, propertiesToIgnoreNull, typesToIgnoreNull); }