Support for return type of MS JavascriptSerializer #199

yelouafi opened this Issue Sep 13, 2013 · 1 comment


None yet
2 participants


i'm using your Code in a small Webmatrix Project and ran into a 'minor' issue wile working on json deserialization.

actually i'm using System.Web.Script.Serialization.JavaScriptSerializer to parse my json payloads sent from the browser.

it seems the return type of JavaScriptSerializer.DeserializeObject is not supported by the 'RecordToExpando' method. tracing execution lead me to this bloc in the method

         public static dynamic RecordToExpando(this IDataReader rdr) {
           else {
                           var props = o.GetType().GetProperties();

But actually the type returned by the deserializer doesnt handle this method and just returns an empty array of PropertyInfo

Actually the return type is of some

so i tried by inserting this piece of code in the RecordToExpando method

           else if(typeof(IDictionary<string, object>).IsAssignableFrom(o.GetType())) {
                           var dic= (IDictionary<string,object>)o;
                            foreach(var kv in dic)  {
                               d.Add(kv.Key, kv.Value);

           else {
            var props = o.GetType().GetProperties();

and it worked

EDIT just

           else if(typeof(IDictionary<string, object>).IsAssignableFrom(o.GetType())) {                              
               return o;
           } else {
            var props = o.GetType().GetProperties();

works fine too

Before i tried the Json.Decode helper method in webmatrix but i couldn't figure how to iterate over the properties of the the type returned (some 'System.Web.Helpers.DynamicJsonObject')

so i let you know in case of you where willing to add support of IDictionary int the RecordToExpando method


robconery commented Sep 14, 2013

Part of the reason Massive is a single code file is just this - you can go in and edit for your needs :). I do appreciate you letting me know about this - but I don't think it's a change I want to put into the core.

robconery closed this Sep 14, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment