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); }
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; }