def encode_transit(records):
    '''Returns the records serialized as Transit/json in utf8'''
    with StringIO() as buf:
        writer = Writer(buf, "json")
        writer.write(records)
        return buf.getvalue().encode('utf8')
Returns the records serialized as Transit/json in utf8