MongoDB interview question

Implement a JSON encoder.