How can I get a document in a collection from MongoDB in JSON format, not in array model using PHP?
-
i am new to mongo and php. when i try retrieving document from mongo collection i get in array format. but i need to get it in json format ready. My php page where i am using the mongo act as a responder for a ajax call from javascript. so i just need to get the document and pass to the javascript. is it possible or any way to achieve this other than using json_encode.
-
Answer:
is it possible or any way to achieve this other than using json_encode. No. The driver take BSON (not JSON) from the server and converts it into PHP hash tables (array). Basically all of the drivers do some form of BSON to Object conversion. There is no "switch" in the driver to change this behaviour. You will have to use json_encode.
Gaëtan Voyer-Perrault at Quora Visit the source
Related Q & A:
- How can I get a loan without a job?Best solution by Yahoo! Answers
- How can I get a job at a law firm?Best solution by Yahoo! Answers
- How can I get a job as a White House tour officer?Best solution by Yahoo! Answers
- How can I get a job as a personal shopper?Best solution by Yahoo! Answers
- How can I get a job as a Bridal Retail Sales Associate?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.