phpmongodb / phpmongodb-1

http://www.phpmongodb.org
GNU General Public License v3.0
82 stars 39 forks source link

JSON formatting isn't correct JSON #16

Closed c00 closed 9 years ago

c00 commented 9 years ago

When viewing the content of a collection, there's three choices of displaying the data: JSON, Array or MongoCursor. I haven't checked the other two as I don't really know the definitions for it, but the JSON one, does not display JSON data according to the JSON standards. Example of output:

{
    '_id': ObjectId("55d755d46ac2fe071cc919f4"),
    'name': 'Bob the Builder',
    'picture': {
        'url': 'http://example.com/profiles/3.jpg',
        'hash': 'efgh'
    }
}

There's two main problems with this. Strings are encapsulated with single quotes, JSON required it to be double quotes. The ObjectId("sdfsd") is not a valid structure in Json. The correct notation of this example would be:

{
    "_id": { "$id": "55d755d46ac2fe071cc919f4" },
    "name": "Bob the Builder",
    "picture": {
        "url": "http://example.com/profiles/3.jpg",
        "hash": "efgh"
    }
}

Is this project still being actively maintained? Or should I find my own solution? Cheers!

phpmongodb commented 9 years ago

Thank You for your suggestion . actually i am showing how mongodb stores data internally

c00 commented 9 years ago

You might want to rename the tab to BSON then, as that is the format. Tho I would really love a JSON tab as well!

phpmongodb commented 9 years ago

Thank your for your suggestion we can create one tab for json and other is Bson