mgholam / fastJSON

Smallest, fastest polymorphic JSON serializer
https://www.codeproject.com/Articles/159450/fastJSON-Smallest-Fastest-Polymorphic-JSON-Seriali
MIT License
478 stars 148 forks source link

add JSONParameters.SerializeDefaultValues #114

Closed ychenming closed 3 years ago

ychenming commented 4 years ago

JsonSerializer.cs: private Dictionary<Type, object> _defaults = new Dictionary<Type, object>(); if (_params.SerializeNullValues == false && (o == null || o is DBNull)) { //append = false; } else { // add start if (!_params.SerializeDefaultValues && o.GetType().IsValueType) { object def; if (!_defaults.TryGetValue(o.GetType(), out def)) { def = _defaults[o.GetType()] = Activator.CreateInstance(o.GetType()); } if (o.Equals(def)) continue; } // add end if (append) _output.Append(',');

mgholam commented 4 years ago

??