JavaScriptSerializer has registerconverters, how to call base deserialize method in RegisterConverts Class RRS feed

  • Question

  • Hi

    I want to call base Deserialize Method from RegisterConverters Class.  Please look at the code below.

    public class DefaultNullPropertiesConverter : JavaScriptConverter
        public override object Deserialize(IDictionary<string, object> dictionary, Type type, JavaScriptSerializer serializer)
    //how to call base Deserialize method here?????
            throw new NotImplementedException();
        public override IDictionary<string, object> Serialize(object obj, JavaScriptSerializer serializer)
            var jsonExample = new Dictionary<string, object>();
            foreach (var prop in obj.GetType().GetProperties())
                //check if decorated with ScriptIgnore attribute
                bool ignoreProp = prop.IsDefined(typeof(ScriptIgnoreAttribute), true);
                var value = prop.GetValue(obj, BindingFlags.Public, null, null, null);
                if (value != null && !ignoreProp)
                    if (value.GetType().FullName == "System.DateTime" && Convert.ToDateTime(value) == DateTime.MinValue)
                    else if (value.GetType().FullName == "System.DateTime")
                        jsonExample.Add(prop.Name, Convert.ToDateTime(value).ToString("yyyy-MM-dd"));
                        jsonExample.Add(prop.Name, value);
            return jsonExample;
        public override IEnumerable<Type> SupportedTypes
            get { return GetType().Assembly.GetTypes(); }

    var restGeoCodeResponse rgcr = jss.Deserialize<restGeoCodeResponse>(result);

    I think, we can not call base Deserialize method since it is an interface, we are just implementing it.  Ok I don't want to do anything to my input Json String coming into this Deserialze method Directory input parameter.  It should Deserialize automatically.  What should I return here??

    • Edited by AreefAli Tuesday, March 26, 2013 10:04 AM
    Tuesday, March 26, 2013 9:33 AM