Example #1
0
        public PoolItem <T> Take(Newtonsoft.Json.NullValueHandling nullValueHandling)
        {
            PoolItem <T> item = base.Take();

            ((GoogleJsonSerializer)item.Item.Serializer).NullValueHandling = nullValueHandling;
            return(item);
        }
 public JsonSerializer()
 {
     this._referenceLoopHandling      = Newtonsoft.Json.ReferenceLoopHandling.Error;
     this._missingMemberHandling      = Newtonsoft.Json.MissingMemberHandling.Ignore;
     this._nullValueHandling          = Newtonsoft.Json.NullValueHandling.Include;
     this._defaultValueHandling       = Newtonsoft.Json.DefaultValueHandling.Include;
     this._objectCreationHandling     = Newtonsoft.Json.ObjectCreationHandling.Auto;
     this._preserveReferencesHandling = Newtonsoft.Json.PreserveReferencesHandling.None;
     this._constructorHandling        = Newtonsoft.Json.ConstructorHandling.Default;
     this._typeNameHandling           = Newtonsoft.Json.TypeNameHandling.None;
     this._context = JsonSerializerSettings.DefaultContext;
     this._binder  = DefaultSerializationBinder.Instance;
 }
Example #3
0
        /// <summary>
        /// 将对象序列化为JSON字符串,循环引用的对象将被忽略
        /// </summary>
        /// <param name="value"></param>
        /// <param name="formatting"></param>
        /// <param name="settings"></param>
        /// <param name="nullValue"></param>
        /// <param name="referenceLoop"></param>
        /// <returns></returns>
        public static string ToJson(this object value,
                                    Newtonsoft.Json.Formatting formatting               = Newtonsoft.Json.Formatting.None,
                                    Newtonsoft.Json.NullValueHandling nullValue         = Newtonsoft.Json.NullValueHandling.Ignore,
                                    Newtonsoft.Json.ReferenceLoopHandling referenceLoop = Newtonsoft.Json.ReferenceLoopHandling.Ignore,
                                    Newtonsoft.Json.JsonSerializerSettings settings     = null)
        {
            if (settings == null)
            {
                settings = new Newtonsoft.Json.JsonSerializerSettings()
                {
                    ReferenceLoopHandling = referenceLoop, // 忽略循环引用
                    NullValueHandling     = nullValue,
                };
            }
            var json = Newtonsoft.Json.JsonConvert.SerializeObject(value, formatting, settings);

            return(json);
        }
Example #4
0
 public JsonSerializer()
 {
     Class6.yDnXvgqzyB5jw();
     base();
     this._referenceLoopHandling      = Newtonsoft.Json.ReferenceLoopHandling.Error;
     this._missingMemberHandling      = Newtonsoft.Json.MissingMemberHandling.Ignore;
     this._nullValueHandling          = Newtonsoft.Json.NullValueHandling.Include;
     this._defaultValueHandling       = Newtonsoft.Json.DefaultValueHandling.Include;
     this._objectCreationHandling     = Newtonsoft.Json.ObjectCreationHandling.Auto;
     this._preserveReferencesHandling = Newtonsoft.Json.PreserveReferencesHandling.None;
     this._constructorHandling        = Newtonsoft.Json.ConstructorHandling.Default;
     this._typeNameHandling           = Newtonsoft.Json.TypeNameHandling.None;
     this._metadataPropertyHandling   = Newtonsoft.Json.MetadataPropertyHandling.Default;
     this._context             = JsonSerializerSettings.DefaultContext;
     this._serializationBinder = DefaultSerializationBinder.Instance;
     this._culture             = JsonSerializerSettings.DefaultCulture;
     this._contractResolver    = DefaultContractResolver.Instance;
 }