I am writing a bot for vk.com, which will post pictures on the group page. There is such a function:
upload_url = api.photos.getWallUploadServer(group_id=Settings.owner_id) files = {'photo': open('img/img.jpg', 'rb')} r = requests.post(upload_url["upload_url"], files=files) # отправляем файл print(r.text) dict_param = json.loads(r.text) # Парсим json server = dict_param["server"] hash_photo = dict_param["hash"] photo = dict_param["photo"] save = api.photos.saveWallPhoto(group_id="143550839", server=server, hash=hash_photo, photo=photo) saveWallPhoto returns the following error: vk.exceptions.VkAPIError: 121. Invalid hash. Googling, I learned that such an error may occur due to decoding JSON, which is returned by the server and is stored in my variable r. How to access JSON values without decoding it?
r.json(), notjson.loads(r.text)2- forget the advice that says that you should get information from a json document using something other than the json parser (or you misunderstand bad advice). - jfs