[SERVER-5543] mongoimport should support ISODate() format for import Created: 09/Apr/12 Updated: 15/Aug/12 Resolved: 09/Apr/12 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Tools |
| Affects Version/s: | 2.1.0 |
| Fix Version/s: | None |
| Type: | New Feature | Priority: | Major - P3 |
| Reporter: | Alvin Richards (Inactive) | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Participants: | |||||||||
| Description |
|
Problem: It will fail with the following error Mon Apr 9 09:06:09 Assertion: 10340:Failure parsing JSON string near: , "ts" : I Solution: Test case: > db.foo.save( {name:"bob", ts: ISODate("2012-04-09")}); > db.foo.find( {name:"bob"}); { "_id" : ObjectId("4f82992047a6783d6427f207"), "name" : "bob", "ts" : ISODate("2012-04-09T00:00:00Z") }> exit cut & paste that object into a file , e.g. tmp/3/json $ mongoimport -d test -c foo /tmp/3.json |
| Comments |
| Comment by Scott Hernandez (Inactive) [ 21/Apr/12 ] | ||
|
I created the general issue here ; So all extended formats and outputs by the shell are supported. Please feel free to vote that issue up. | ||
| Comment by Scott Hernandez (Inactive) [ 21/Apr/12 ] | ||
|
Dave, that is not json, it is just something the shell can interpret, since it is an object definition/function. The shell is more than a json parser. The printjson function is unfortunately named since really it is not json, in the standard meaning. You can also see the "extended" json format here for a better understanding : http://www.mongodb.org/display/DOCS/Mongo+Extended+JSON | ||
| Comment by Dave Elliot [ 21/Apr/12 ] | ||
|
But if you use a mongo command like this:
It renders the date fields using ISODate, like:
So it's printing JSON in a format that you can't import? | ||
| Comment by Scott Hernandez (Inactive) [ 09/Apr/12 ] | ||
|
This is the incorrect format for both ObjectId and ISODate in a json file, and not the format from mongoexport. Your example should look like this:
|