code: def _parse_json(self, doc, exactly_one):
          
          places = doc.get('geonames', [])
          self._raise_for_error(doc)
          if not len(places):
              return None
  
          def parse_code(place):
              """
              Parse each record.
              """
              latitude = place.get('lat', None)
              longitude = place.get('lng', None)
              if latitude and longitude:
                  latitude = float(latitude)
                  longitude = float(longitude)
              else:
                  return None
  
              placename = place.get('name')
              state = place.get('adminName1', None)
              country = place.get('countryName', None)
  
              location = ', '.join(
                  [x for x in [placename, state, country] if x]
              )
  
              return Location(location, (latitude, longitude), place)
  
          if exactly_one:
              return parse_code(places[0])
          else:
              return [parse_code(place) for place in places]
docs: Parse JSON response body.