I used the mongoexport to export a collection to json file (script as below).
mongoexport -d db1 -c user --out /root/user_130226.json
Found that those parameters with type "NumberLong" were saved without word "NumberLong", so when I use mongoimport, the word "NumberLong" is missing too.
Same if using mongodump and mongorestore.
Example:
source :
>> "cd" : NumberLong(1361862291)
output and imported to new collection :
>> "cd" : 1361862291
But if the NumberLong with quote in bracket (), the it exported and imported accordingly.
Example:
"u4" : NumberLong("111018951303058"),
Questions:
- Is it correct to save the NumberLong without quote ?
It seem like it's the behavior of Mongo, depending on the length of the number. Did further test by parse in different length of number.
- Does it matter if the word "NumberLong" is not being exported ?
Since with or without quote are correct and it's behavior of Mongo. Hence NumberLong() will be removed when exporting with using mongoexport/mongodump should consider correct too.