Implementation of JSONEncoder