从json响应

时间:2017-01-21 15:12:26

标签: python json google-app-engine google-cloud-endpoints

我需要使用python访问google端点模型API的JSON_array响应格式中的单个值,如何访问它。

我想从响应中访问值并进行操作以传递给其他类,我该怎么做。

我尝试了以下代码,但它提供了整个json数组数据:

@Gadget.query_method(path='gadgets', name='gadget.list', query_fields=  ('ownerID', 'category', 'locationCity','pageToken'))

def GadgetList(self, query):
    return query

如何提取我需要的单个值?

我得到了回应。

    {        
     "items": [
      {
       "category": "Audio",
       "locationBuilding": "100",
       "subCategory": "Microphone",
       "title": "qwe",
       "description": "hdhsjsjsbs ks\nshshs josh\nvsdbjddkdkdldjdj       \nhsjdkdkdldlddhdhdkslsksmsnsbsnksslslsl",
       "accountNumber": "1246800754379",
       "image_name": "test_image.png",
       "created": "2017-01-25T07:51:30.468280",
       "locationPostCode": "10040",
       "reviews": "0",
       "locationCity": "Stockholm",
       "ownerName": "Canopus Rise",
       "locationStreet": "wash",
       "image_first": "https://folkloric-drive-119608.appspot.com/view_photo/AMIfv95kf_NH4IjVPwyzUH2owYG7RA604yij9zeQO_WrgKe2YtKS4UXyfQP4qNzB92OqEsNZSPKg2KVX_ZxbixkX24cpeIimYFzarpjScAWbLzGFQsVZ2FZ68KMLCEqgNZslmdlWB11WlGDapeStzqNklg_AMrgxymugGPdGEGYsrfN4tV2ZjMEwqPSBysByMzWVCIABlaFkdhzYNrAOdUKBq6KoFMO1AVTW8VCB48OKEba59iIsJ2vLDbFD0xwna9Ef8ey2njve2ytXd7yLngaiI4AqCWGRqPKwPlVhdJig1oaTcf7L89Y2dBJsKqmczAHQpQY7OYhtduvwmY2RJERjn_DJR946oyiHJyYvqTptJS6hmTHySTLGF64tYp1OhzXKPVkXcwCJo2st-WrxrXITw4VAEBsAH5ALlAI9WaXNrvZjE3uIHUYbDZLWxtHmXUD",
       "ownerID": "5723151296102400",
       "image_second": "https://folkloric-drive-119608.appspot.com/view_photo/AMIfv967Q-nOvyX9I5qCyhdFQ-Y_ltXzcPX0BfSsDrWOL4BcepNCP9kYg3qyy3af2Q6uAnQuzDA-pcYj_abrp9CkEkVbt8c3nJuJGa5X0TpKZr4rWyQiat7WbhN3vJ7Z1mqSpalAT3VGZNMiZUopQ37lJA2BhArKtfe_S5Pyqi61pxROoFawKNsMGRupzBy3Z3xHGTuqaIA3hK1rpu7PXwlGxKf3t_lEdwklgz2myUsCK9A6iynJDY1_E8are6GKtGjgVDKKgDwzQp6A6lwcDEVwbYKnbcxaxaVtxIt3Cl54OM32z2dT0Ai9SDTKaxCU82SUwbPM_9KdmnwpDWfvmkdlFEuXgDXtyXH2N8R9ll6PxSWkNRNC34pzsLsviGypahaKTfmn86Rivr8r9IhAo4QIQGelIcjsT7L0-jJ1I8zkUYxUiZ8_8H6fBuMtNwEhpppzO5hjt",
       "price": 25,
       "id": "5690964005879808",
       "image_third": "https://folkloric-drive-119608.appspot.com/view_photo/AMIfv94CvfaeiODVYShFYtr39sV6tILqcOH25GMwyRqum_I6hby2wu08izp7f0pJ27VFZ4YWnSScH_tS1fu-I8L_fOGQjFXXdiO444plR8F4h33CWzwBXltazPPGIC1GS5BKDSz31jtr8wtViG-0wFd-q-QIsrL3kyfr7qdebfKkwkjeX82hXpdu6kIhIvLqaxXoCPGORZWRtxPTrzsBxuDPy4ISApB3_MgmCSqLhtUVjwAZIrCwv47f1q9JCusuqBn04Qv3GGE017rlocFFgz0BCEFc_Sjeo058OS8GOTBNVRPQA8_tViCEWghWe78USvOFloRLVk_k9T1B1rSVcJsq0DATZp_Jxp_KBA2DLrTkvVk0DXJANABjhTGtZwJpUwbly_LSfl294Ux65i_GSENpyEi7_tRpgHOQ6Jj9BtvC0pTxpF2M8c2jgbnKROoWxBqnvcC_Gk9z",
       "ownerPic": "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-ash2/v/t1.0-1/p200x200/10262183_278529225690836_3880829709913861761_n.jpg?oh=d252a7fe35be82049a8af84035167d41&oe=58400F76&__gda__=1481700277_70deb0cd0b615a544844d9444a599a6b",
       "kind": "shareclub#gadgetItem"
      }
     ],
     "kind": "shareclub#gadget",
     "etag": "\"I7-yHEADuMxTlz3eOecr1LwL2AQ/z2piY1JoP7KGAyKRBlO72PmSj74\""
       }

0 个答案:

没有答案