I have the following json:
{
"dolphins": "Whether the oceans will contain dolphins.",
"dolphins": false,
"jellyfish": "How many jellyfish are present. Zero to disable jellyfish.",
"jellyfish": 7000
}
When I insert it into my collection via "Insert Document UI", it saves as
{
"_id" : ObjectId("5243311918f524ca2bdfc738"),
"dolphins" : "Whether the oceans will contain dolphins.",
"dolphins" : false,
"jellyfish" : "How many jellyfish are present. Zero to disable jellyfish.",
"jellyfish" : 7000
}
Its not correct behavior.
BUT when I insert the same document via Robomongo shell as db.test.insert({...}), it saves correctly:
{
"_id" : ObjectId("5243310b90e5e7cf448c86d2"),
"dolphins" : false,
"jellyfish" : 7000
}
Nice! Really interesting :)
According to the current JSON spec, there is no support for comments: http://www.json.org.
The behaviour difference in this example is because:
Problems will arise when trying to query the documents with duplicate keys from most drivers or the standard mongo shell, as the typical representation of a BSON document as a hash or dictionary does not provide predictable results with duplicate keys.
So the "correct" fix is probably for users to not use JSON "comments" hack as this is non-standard and makes some assumptions on how duplicate keys are handled. A friendlier fix might be to implement the expected behaviour of "last value wins" when parsing JSON. Seems like Qt's JSON parser should already be enforcing this (if it's even applicable here): http://qt-project.org/doc/qt-5.1/qtcore/json.html.
Cheers,
Stephen
This is another consistency issue for the JSON validation used in the Robomongo Insert Document UI versus mongo shell (eg #335, #448). Not sure if we should rename either this issue or #448 to be specific to matching mongo validation .. or would be better creating a new ticket linking to the current differences (which are adding up!).
Is this related to the problem where comments such as:
/* 1 */
(Which are generated by RoboMongo itself btw)
cause a problem when trying to mass-insert records?
yes
Most helpful comment
Is this related to the problem where comments such as:
/* 1 */(Which are generated by RoboMongo itself btw)
cause a problem when trying to mass-insert records?