从错误中,我推断这referenceElement
是一个字典(请参阅下面的repro)。字典不能被散列,因此不能用作另一个字典的键(或本身就是这个键!)。
>>> d1, d2 = {}, {}
>>> d1[d2] = 1
Traceback (most recent call last):
File "<input>", line 1, in <module>
TypeError: unhashable type: 'dict'
您可能意思是for element in referenceElement.keys()
或for element in json['referenceElement'].keys()
。如果这两种解决方案都不起作用,那么在有关什么类型json
和referenceElement
是什么以及它们包含什么的更多上下文中,我们将能够为您提供更好的帮助。