示例#1
0
def to_json(data):
    """Returns a string JSON representation using the same mechanism as the Piston based APIs"""
    handler = get_handler(type(data), False)
    if not handler:
        handler = PlainObjectHandler()
        data = PlainObjectHandler().flatten(data)
    emitter = JSONEmitter(data, typemapper, handler, anonymous=False)
    request = HttpRequest()
    request.method = "GET"
    return emitter.render(request)