我有一个JSON字符串,当我尝试将其转换为JSON时,我可以在postrequest中将其用作变量,缺少一个元素。此后,帖子请求失败并显示"TypeError: 'Response' object has no attribute '__getitem__'"
字符串是:
${data}= Set Variable {"elementKey":"P690-C0-C3-B1","fields":[{"key":"P690-C1-C2-C1-C1-C1-F0","values":[]},{"key":"P690-C0-C2-F8","values":["1200"]},{"key":"P690-C0-C2-F9","values":["22000"]},{"key":"P690-C0-C2-F11","values":["I"]},{"key":"P690-C0-C2-F10","values":["2200"]},{"key":"P690-C0-C2-C0-C0-F0","values":["98-zsg-2"]},{"key":"P690-C1-C0-C0-F1","values":["Personenauto"]},{"key":"P690-C1-C0-C0-F2","values":["ASR - Personenauto VVP"]},{"key":"P690-C0-C2-F6","values":["B"]},{"key":"P690-C0-C2-F7","values":["75"]},{"key":"P690-C0-C2-F4","values":["2"]},{"key":"P690-C0-C2-F5","values":["5"]},{"key":"P690-C0-C2-F2","values":["model"]},{"key":"P690-C0-C2-F3","values":["2017"]},{"key":"P690-C1-C2-C2-C2-C1-F0","values":[]},{"key":"P690-C0-C2-F1","values":["merk"]}]}
${data}= to json ${data}
结果$ {data} =
${data} = {u'fields': [{u'values': [], u'key': u'P690-C1-C2-C1-C1-C1-F0'}, {u'values': [u'1200'], u'key': u'P690-C0-C2-F8'}, {u'values': [u'22000'], u'key': u'P690-C0-C2-F9'}, {u'values': [u'I'], u'key': u'P690...
正如您所见,“elementKey”:“P690-C0-C3-B1”消失了。我在这里失踪了什么?
这也可能是我的帖子请求失败${data} = {}, "TypeError: 'Response' object has no attribute '__getitem__'"?