Ejemplo n.º 1
0
        private dynamic getDynamicJsonObject(dynamic data)
        {
            if (data is IDictionary <string, object> && ((IDictionary <string, object>)data).Count > 0)
            {
                data = new DynamicJsonObject((IDictionary <string, object>)data);
            }
            else if (data is IList && ((IList)data).Count > 0)
            {
                IList iterate = data as IList;
                IDictionary <string, object> res = new Dictionary <string, object>(iterate.Count);
                for (int i = 0; i < iterate.Count; i++)
                {
                    res.Add(i.ToString(), iterate[i]);
                }

                data = new DynamicJsonObject((IDictionary <string, object>)res);
            }
            return(data);
        }
Ejemplo n.º 2
0
        private dynamic getDynamicJsonObject(dynamic data)
        {
            if (data is IDictionary<string, object> && ((IDictionary<string, object>)data).Count > 0)
                data = new DynamicJsonObject((IDictionary<string, object>)data);
            else if (data is IList && ((IList)data).Count > 0)
            {
                IList iterate = data as IList;
                IDictionary<string, object> res = new Dictionary<string, object>(iterate.Count);
                for (int i = 0; i < iterate.Count; i++)
                    res.Add(i.ToString(), iterate[i]);

                data = new DynamicJsonObject((IDictionary<string, object>)res);
            }
            return data;
        }