def dictToDataset(dictValue):
data = []
columns = dictValue[“employ”][0].keys()
for obj in dictValue[“Root”]:
row = []
for column in columns: #print(column)
row.append(obj[column])
data.append(row)
return system.dataset.toDataSet(columns,data)
My final code, reading from Dynamic Navision2013, reading employee list via sepasoft web service
def dictToDataset(dictValue):
data = []
columns = dictValue[‘Root’][‘ReadMultiple_Result’][‘ReadMultiple_Result’][‘employ’][0].keys()
i = 0
for obj in dictValue['Root']['ReadMultiple_Result']['ReadMultiple_Result']['employ']:
row = []
for column in columns:
if column in dictValue['Root']['ReadMultiple_Result']['ReadMultiple_Result']['employ'][i].keys():
row.append(obj[column])
else:
row.append("")
data.append(row)
i = i + 1
return system.dataset.toDataSet(columns,data)
Ah I see I’ve led you astray a bit in this regard since the Sepasoft webservice request converts the SOAP response into a JSON-ish looking structure when stringified.
If you’re willing to play with it a bit more you can probably simplify your code and reduce a lot of the processing needed by doing something more like this: