MongoDB Interview Question

Implement a JSON encoder.