Breeze.Entities.BreezeEntityBuilder.JsonToDictionary C# (CSharp) Method

JsonToDictionary() protected static method

Convert the json object to a dictionary.
protected static JsonToDictionary ( dynamic json ) : Object>.Dictionary
json dynamic Object assumed to be an IEnumerable containing JProperty objects
return Object>.Dictionary
        protected static Dictionary<String, Object> JsonToDictionary(dynamic json)
        {
            if (json == null) return null;
            var jprops = ((System.Collections.IEnumerable)json).Cast<JProperty>();
            var dict = jprops.ToDictionary(jprop => jprop.Name, jprop => {
                var val = jprop.Value as JValue;
                if (val != null)
                {
                    return val.Value;
                }
                else if (jprop.Value as JArray != null)
                {
                    return jprop.Value as JArray;
                }
                else
                {
                    return jprop.Value as JObject;
                }
            });
            return dict;
        }