I’m working with a streaming API response in Python and having trouble with Unicode formatting. When I fetch data from the API, everything comes back with unicode prefixes like u'key'
instead of regular strings.
import requests
import json
api_endpoint = 'https://api.example.com/streams/data.json?user=streamer123'
response = requests.get(api_endpoint, timeout=60)
data = response.json()
print(data)
The output shows something like:
[{u'stream_id': 12345, u'is_live': True, u'viewer_count': 1500, u'game_title': u'Popular Game Title', u'streamer_info': {u'username': u'streamer123', u'follower_count': 50000, u'stream_title': u'Epic Gaming Session'}}]
How can I convert this Unicode dictionary into a normal string dictionary that I can work with properly?