I’m trying to access the ‘city’ proprety of this json but somehow it doesn’t work , this is the json struct :
{ "ForSaleShopperPlatformFullRenderQuery{"zpid":28657235,"platform":"DESKTOP_WEB","formType":"OPAQUE","contactFormRenderParameter":{"zpid":28657235,"platform":"desktop","isDoubleScroll":true},"skipCFRD":false,"ompPlatform":"web"}": { "property": { "listingDataSource": "Phoenix", "zpid": 28657235, "city": "Boerne", "state": "TX", "homeStatus": "FOR_SALE", "address": { "streetAddress": "111 stone creek", "city": "Boerne", "state": "TX", "zipcode": "78006", "neighborhood": null, "community": null, "subdivision": null },
this is the code :
key = 'ForSaleShopperPlatformFullRenderQuery{"zpid":28657235,"platform":"DESKTOP_WEB","formType":"OPAQUE","contactFormRenderParameter":{"zpid":28657235,"platform":"desktop","isDoubleScroll":true},"skipCFRD":false,"ompPlatform":"web"}' city = data["props"]["pageProps"]["componentProps"]["gdpClientCache"][key]['property']['city']
i get error :
print(data["props"]["pageProps"]["componentProps"]["gdpClientCache"]['ForSaleShopperPlatformFullRenderQuery{\"zpid":28657235,\"platform\":\"DESKTOP_WEB\",\"formType\":\"OPAQUE\",\"contactFormRenderParameter\":{\"zpid\":28657235,\"platform\":\"desktop\",\"isDoubleScroll\":true},\"skipCFRD\":false,\"ompPlatform\":\"web\"}']) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: string indices must be integers, not 'str'
tried also
key = "ForSaleShopperPlatformFullRenderQuery{"zpid":28657235,"platform":"DESKTOP_WEB","formType":"OPAQUE","contactFormRenderParameter":{"zpid":28657235,"platform":"desktop","isDoubleScroll":true},"skipCFRD":false,"ompPlatform":"web"}"
still doesn’t work
Saad Ouled Lafqui is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.