Did I find the right examples for you? yes no

All Samples(5)  |  Call(3)  |  Derive(0)  |  Import(2)
Encode stream of JSON with 7-digits floating point precision.
    

        def json_encode(data):
    ''' Encode stream of JSON with 7-digits floating point precision.
    '''
    encoder = JSONEncoder(separators=(',', ':'))
    encoded = encoder.iterencode(data)
    output = StringIO()
    
    for token in encoded:
        if charfloat_pat.match(token):
            # in python 2.7, we see a character followed by a float literal
            output.write(token[0] + '%.7f' % float(token[1:]))
        
        elif float_pat.match(token):
            # in python 2.6, we see a simple float literal
            output.write('%.7f' % float(token))
            
        else:
            output.write(token)
    
    return output.getvalue()
        


src/u/s/US-Census-Area-API-HEAD/app.py   US-Census-Area-API(Download)
from osgeo import ogr
 
from util import json_encode, bool
from geo import features_geojson, QueryError
from geo import get_intersecting_features, get_matching_features
        }
 
    body = json_encode(status)
 
    return Response(body, headers={'Content-type': 'application/json', cors: '*'})
 
    except QueryError, e:
        body, mime = json_encode({'error': str(e)}), 'application/json'
 
        if json_callback:

src/u/s/US-Census-Area-API-HEAD/geo.py   US-Census-Area-API(Download)
from shapely import wkb
from util import json_encode
 
class QueryError (RuntimeError):
    pass
def features_geojson(features, json_callback):
    '''
    '''
    geojson = dict(type='FeatureCollection', features=features)
    body, mime = json_encode(geojson), 'application/json'