vendredi 8 mai 2015

Parsing JSON data from Yelp API

I'm new to programming and am trying to parse some data returned from Yelp's API. From this data, how could I return something like just the phone number (display_phone) and address? Thank you

Result for business "little-miss-bbq-phoenix-2" found:
{ u'categories': [[u'Barbeque', u'bbq']],
  u'display_phone': u'+1-602-437-1177',
  u'id': u'little-miss-bbq-phoenix-2',
  u'image_url': u'http://ift.tt/1DXoWIP',
  u'is_claimed': True,
  u'is_closed': False,
  u'location': { u'address': [u'4301 E University Dr'],
                 u'city': u'Phoenix',
                 u'coordinate': { u'latitude': 33.421587,
                                  u'longitude': -111.989088},
                 u'country_code': u'US',
                 u'display_address': [ u'4301 E University Dr',
                                       u'Phoenix, AZ 85034'],
                 u'geo_accuracy': 9.5,
                 u'postal_code': u'85034',
                 u'state_code': u'AZ'},
  u'mobile_url': u'http://ift.tt/1JVI9CL',
  u'name': u'Little Miss BBQ',
  u'phone': u'6024371177',
  u'rating': 5.0,
  u'rating_img_url': u'http://ift.tt/WVmntb',
  u'rating_img_url_large': u'http://ift.tt/WVmntd',
  u'rating_img_url_small': u'http://ift.tt/1o2fewz',
  u'review_count': 403,
  u'reviews': [ { u'excerpt': u"I saw that this place had almost 400 reviews and that they have a perfect 5 star rating. It sounded too good to be true BUT it's worth every star and...",
                  u'id': u'-9poa0ycpVnOveVlqbYE9Q',
                  u'rating': 5,
                  u'rating_image_large_url': u'http://ift.tt/WVmntd',
                  u'rating_image_small_url': u'http://ift.tt/1o2fewz',
                  u'rating_image_url': u'http://ift.tt/WVmntb',
                  u'time_created': 1431095420,
                  u'user': { u'id': u'd43iQ50HjWIl4vN4rBgoVQ',
                             u'image_url': u'http://ift.tt/1JVI8yX',
                             u'name': u'Jason J.'}}],
  u'snippet_image_url': u'http://ift.tt/1JVI8yX',
  u'snippet_text': u"I saw that this place had almost 400 reviews and that they have a perfect 5 star rating. It sounded too good to be true BUT it's worth every star and...",
  u'url': u'http://ift.tt/1IobOkA'}

Aucun commentaire:

Enregistrer un commentaire