title: Cannot JSON serialize python Appengine GeoModel subclass using simple json
body: <p>I am working on a simple app engine application that utilize the geo-searching proximity_fetch.</p>
  
  <p>I perform the search and some extra filtering on the data, and all goes well (I checked the number of returned results, and it was just as expected ) However, when I tried to dump it into a json using simple json, I got the following error:</p>
  
  <blockquote>
    <p>TypeError: &lt; backend.models.Listing object at 0x0570CC90 >is not JSON serializable</p>
  </blockquote>
  
  <p>This is the way I define the object in my code:</p>
  
  <pre><code>class Listing(GeoModel):
      currency=db.IntegerProperty( default = CURRENCY["EURO"] )
      title=db.StringProperty(required = True )
      admins = db.ReferenceProperty( User )
      .
      . Some uninteresting properties goes here, Only Integer and String Properties
      .
      active = db.BooleanProperty()
  
      @staticmethod
      def get_listing_from_point( lat , lon ,
                              max_dist=MAX_SEARCH_RADIUS,
                              max_result=MAX_SEARCH_RESULT,
                              start_date=None,end_date=None):
  
          rich_query = Listing.all()
          result = Listing.proximity_fetch( rich_query , 
                                            geo.geotypes.Point( lat , lon ),
                                            max_results = max_result,
                                            max_distance = max_dist )
  
          result =  list( rich_query )
  
          valid_list = 
             [i for i in list( result ) if i.check_availability( start_date , 
                                                                 end_date )]
  
          return  valid_list 
  </code></pre>
  
  <p>And this is the method from which I call the proximity search:</p>
  
  <pre><code>lon = self.request.args.get("lon" , None)
  lat = self.request.args.get("lat" , None)
  check_in = self.request.args.get("check_in" , None)
  check_out = self.request.args.get("check_out" , None)
  if not lon or not lat:
     return Response( json.dumps( "{ 'error' : 'desription..." ) )
  
  result = Listing.get_listing_from_point(
                                  lat = float(lat),
                                  lon = float(lon),
                                  start_date = check_in,
                                  end_date = check_out)
  
  return json.dumps( result )
  </code></pre>
  
  <p>While attempting to find the reason for the problem, I tried to return the <strong>dict</strong> of the first result in the search, and when I did so, I got the following error:</p>
  
  <blockquote>
    <p>TypeError: datastore_types.GeoPt(23.0, 42.2) is not JSON serializable
    Which leads me to believe there is something wrong in the way I handle my geo points...</p>
  </blockquote>
  
  <p>I tried searching for both errors with no result, any clues?</p>
  
  <p>P.S, this is the complete stacktrace:</p>
  
  <blockquote>
    <p>File "C:\Program >Files\Google\google_appengine\google\appengine\ext\appstats\recording.py", line 897, in >appstats_wsgi_wrapper
    result = app(environ, appstats_start_response)</p>
    
    <p>File "C:\Users\roi.SEMANTV\PycharmProjects\gayville_tipfy\tipfy\app.py", line 245, in >dispatch
    rv = self.handle_exception(request, e)</p>
    
    <p>File "C:\Users\roi.SEMANTV\PycharmProjects\gayville_tipfy\tipfy\app.py", line 241, in >dispatch
    rv = self.router.dispatch(request)</p>
    
    <p>File "C:\Users\roi.SEMANTV\PycharmProjects\gayville_tipfy\tipfy\routing.py", line 105, in >dispatch
    rv = rv()</p>
    
    <p>File "C:\Users\roi.SEMANTV\PycharmProjects\gayville_tipfy\tipfy\handler.py", line 297, in ><strong>call</strong>
    response = self.dispatch()</p>
    
    <p>File "C:\Users\roi.SEMANTV\PycharmProjects\gayville_tipfy\tipfy\handler.py", line 88, in >dispatch
    return self.handle_exception(exception=e)</p>
    
    <p>File "C:\Users\roi.SEMANTV\PycharmProjects\gayville_tipfy\tipfy\handler.py", line 86, in >dispatch
    return self.make_response(method(**request.rule_args))</p>
    
    <p>File "C:\Users\roi.SEMANTV\PycharmProjects\gayville_tipfy\backend\handlers.py", line 47, >in get
    return json.dumps( result  )</p>
    
    <p>File "C:\Program >Files\Google\google_appengine\lib\django_0_96\django\utils\simplejson__init__.py", line >182, in dumps
    **kw).encode(obj)</p>
    
    <p>File "C:\Program >Files\Google\google_appengine\lib\django_0_96\django\utils\simplejson\encoder.py", line >312, in encode
    chunks = list(self.iterencode(o))</p>
    
    <p>File "C:\Program >Files\Google\google_appengine\lib\django_0_96\django\utils\simplejson\encoder.py", line >262, in _iterencode
    for chunk in self._iterencode_list(o, markers):</p>
    
    <p>File "C:\Program >Files\Google\google_appengine\lib\django_0_96\django\utils\simplejson\encoder.py", line >170, in _iterencode_list
    for chunk in self._iterencode(value, markers):</p>
    
    <p>File "C:\Program Files\Google\google_appengine\lib\django_0_96\django\utils\simplejson\encoder.py", line 273, in _iterencode
    for chunk in self._iterencode_default(o, markers):</p>
    
    <p>File "C:\Program >Files\Google\google_appengine\lib\django_0_96\django\utils\simplejson\encoder.py", line 279, in _iterencode_default
    newobj = self.default(o)</p>
    
    <p>File "C:\Program >Files\Google\google_appengine\lib\django_0_96\django\utils\simplejson\encoder.py", line >300, in default
    raise TypeError("%r is not JSON serializable" % (o,))</p>
  </blockquote>