title: How to convert MongoDB BSONDocument to valid JSON in PHP?
body: <p>I am using MongoDB with the PHP Library. I inserted a valid JSON document inside MongoDB using PHP. I am now retrieving the document using <a href="http://mongodb.github.io/mongo-php-library/api/class-MongoDB.Collection.html#_findOne" rel="noreferrer" title="findOne Function Definition">findOne</a> and am getting a MongoDB\Model\BSONDocument object as a result. How do I get back my JSON document easily? Is there any inbuilt function or will I have to write logic to convert the BSONDocument to JSON?</p>