Implement toJSON so that it use getter function if available