allows for encoder to be objects. Assumes that object always end on $ and classes never do.