Python Forum
How to process JSON response from requests?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to process JSON response from requests?
#5
Requests as you use has build in JSON decoder.
So then there is no need for separate module like simplejson or json(standard library).
So this should work.
data = clients_service_response.json()
print(data['id'])
Demo.
>>> import requests
>>> 
>>> my_id = '999'
>>> r = requests.post('http://httpbin.org/post', json={"id": my_id})
>>> r.status_code
200
>>> data = r.json()
>>> data['json']['id']
'999'
Reply


Messages In This Thread
RE: How to process JSON response from requests? - by snippsat - Jan-09-2020, 07:49 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Response.json list indices must be integers or slices, not str [SOLVED] AlphaInc 4 6,497 Mar-24-2023, 08:34 AM
Last Post: fullytotal
  Name not found in response json NewbiePyt 4 1,111 Dec-29-2022, 11:12 AM
Last Post: buran
  python requests library .JSON() error mHosseinDS86 6 3,500 Dec-19-2022, 08:28 PM
Last Post: deanhystad
  Python3 requests.models.Response ogautier 4 5,489 Feb-17-2022, 04:46 PM
Last Post: ogautier
  JSON response from REST service get nested value nl2ttl 2 2,556 Nov-30-2020, 09:34 PM
Last Post: nl2ttl
  parser json response absolut 4 2,884 Sep-15-2020, 12:10 PM
Last Post: buran
  Python Requests package: Handling xml response soumyarani 1 2,195 Sep-14-2020, 11:41 AM
Last Post: buran
  Empty response to request causing .json() to error t4keheart 1 10,133 Jun-26-2020, 08:35 PM
Last Post: bowlofred
  API JSON response missing list gives keyerror rolfmadsen 3 3,515 Mar-28-2020, 10:12 AM
Last Post: buran
  Split of key from JSON response aswini_dubey 1 2,437 Dec-04-2019, 06:54 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020