如何从JSON字符串中获取所需内容

PKR*_*PKR 2 python python-2.7 robotframework selenium-webdriver

我在Robot Frame Work中有一个变量,它具有以下格式的Json响应体

{
   "jsonrpc": "2.0",
   "id": "787878",
   "result":
   {
       "content":
       [
           {
               "id": 30,
               "userID": "user",
               "eventType":
               {
                   "name": "test"
               },
               "timestamp": "2013-03-13T11:00:28.537Z",
               "source": "Service",
               "reason": null,
               "comment": null,
               "dataCache":
               {
                   "lastLogin":
                   {
                       "id": 103,
                       "fieldName": "value1",
                       "newValue": "Wed Mar 13 07:00:28 EDT 2013",
                       "oldValue": null,
                       "type": "java.util.Date",
                       "auditEvent": null
                   }
               },
               "authority": "authenticate",
               "auditedObject": null
           }
       ],
       "pageNumber": 0,
       "pageSize": 99,
       "numberOfElements": 1,
       "totalElements": 1,
       "lastPage": true,
       "totalPages": 1
   }

}
Run Code Online (Sandbox Code Playgroud)

从这里我怎么能得到datacache的内容,如下所示

{
   "lastLogin":
   {
       "id": 103,
       "fieldName": "value1",
       "newValue": "Wed Mar 13 07:00:28 EDT 2013",
       "oldValue": null,
       "type": "java.util.Date",
       "auditEvent": null
   }
},
Run Code Online (Sandbox Code Playgroud)

如果我使用变量之类的${variable['result']['content']},我将在内容中获得整个身体但我只想在"DataCache"中使用一个主体:

请帮我解决这个问题..

Sco*_*pil 5

${variable['result']['content'][0]['dataCache']}
Run Code Online (Sandbox Code Playgroud)

这是你在找什么?也许你需要更多JSON练习然后......