-2

I'm using:

import requests

data = 'text=great'

print(requests.post('http://text-processing.com/api/sentiment/', data=data).text)

which returns:

{"probability": {"neg": 0.30135019761690551, "neutral": 0.27119050546800266, "pos": 0.69864980238309449}, "label": "pos"}

and I want to browse that using the structure not just as a string of text. How can I turn it into a dictionary?

Crizly
  • 921
  • 1
  • 11
  • 30

1 Answers1

2

Use the json() method which would load the JSON response content and return you a Python data structure:

response = requests.post('http://text-processing.com/api/sentiment/', data=data)
print(response.json())
alecxe
  • 441,113
  • 110
  • 1,021
  • 1,148