public static GH_Structure <IGH_Goo> DictToGHStruct(string k, Dictionary <string, dynamic> dict) { GH_Structure <IGH_Goo> ghStructure = new GH_Structure <IGH_Goo>(); if (!(dict.Count == 0)) { if (dict.TryGetValue(k, out dynamic _dataDict)) { //if value is a dictionary .. if (_dataDict is Dictionary <string, dynamic> ) { foreach (dynamic _key in _dataDict.Keys) { foreach (dynamic _value in _dataDict[_key]) { if (int.TryParse(_key, out int _result)) { // if dictionary value is a list GH_Path p = new GH_Path(_result); if (_value is List <dynamic> ) { for (int i = 0; i < _value.Count; i++) { IGH_Goo goo = null; if (goo.CastFrom(_value[i])) { ghStructure.Insert(goo, p, i); } } } // if dictionary value is a single item else { IGH_Goo goo = null; if (goo.CastFrom(_value)) { ghStructure.Insert(goo, p, 0); } } } } } } /// if its a list else if (_dataDict is List <dynamic> ) { GH_Path p = new GH_Path(int.Parse(k)); for (int i = 0; i < _dataDict.Count; i++) { //if (GH_Goo.CastFrom(_dataDict[i])) // ghStructure.Insert(goo, p, i); } } else { GH_Path p = new GH_Path(int.Parse(k)); IGH_Goo goo = null; if (goo.CastFrom(_dataDict)) { ghStructure.Insert(goo, p, 0); } } } } return(ghStructure); }