In case others end up fighting this later and are having trouble finding the bad sub-elements of a bigger structure, this is a quick bit of debug code I put together to show the data types of a structure before passing it into jsonEncode
:
def type_tree(element, prefix='/'):
type_string = str(type(element))
output_string = '{}={}\n'.format(prefix, type_string)
if hasattr(element, '__iter__'):
if hasattr(element, 'keys'):
for key in element.keys():
output_string = output_string + type_tree(element[key], '{}[{}]'.format(prefix, key))
else:
for x, val in enumerate(element):
output_string = output_string + type_tree(val, '{}[{}]'.format(prefix, x))
return output_string