0

I am trying to retrieve a particular value from a JSON data.

This is the API that gives JSON Data :- http://data.ehealthireland.ie/api/3/action/datastore_search?resource_id=967673a3-1ce0-47e0-8e09-c876894ad489

import urllib.request
url = 'http://data.ehealthireland.ie/api/3/action/datastore_search?resource_id=967673a3-1ce0-47e0-8e09-c876894ad489'  
fileobj = urllib.request.urlopen(url)
print (fileobj.read())

How can I access the first Speciality Value in the JSON Data ?

The answers for the Identified duplicate question doesn't help me to understand the problem in this question. Sorry.

5
  • The answers for the Identified duplicate question doesn't help me to understand the problem in this question. Sorry. Commented Apr 23, 2018 at 22:53
  • I tried this SpecialtyName= fileobj['records']['Specialty'][1] and it didn't help. Commented Apr 23, 2018 at 22:58
  • 1
    Use d = json.loads(fileobj.read().decode()) SpecialtyName = d['result']['records'][0]['Speciality'] Commented Apr 23, 2018 at 23:01
  • Yes, That works for me. Thanks. Commented Apr 23, 2018 at 23:02
  • what you get you must convert it to a string and then convert it to a dictionary, then you use the magic of the keys and index. Commented Apr 23, 2018 at 23:04

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.