MongoImport question

170 views
Skip to first unread message

WDB

unread,
May 16, 2012, 9:07:21 AM5/16/12
to mongodb-user
DOS files with line control characters don't seem to import. The
following error is generated for every line in the import file:

Wed May 16 08:59:45 Assertion: 10340:Failure parsing JSON string
near: }
exception:Failure parsing JSON string near: }

Removing the line control characters allows the import to work. Is
there a better way?

Scott Hernandez

unread,
May 16, 2012, 9:46:49 AM5/16/12
to mongod...@googlegroups.com

Can you post a sample to gist/pastie so we can test it?

--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com
To unsubscribe from this group, send email to
mongodb-user...@googlegroups.com
See also the IRC channel -- freenode.net#mongodb

WDB

unread,
May 16, 2012, 9:58:49 AM5/16/12
to mongodb-user
Windows 7 Professional, 64-bit
mongodb-win32-x86_64-2008plus-2.0.4

Doesn't import:
<menu id="file" value="File">
<popup>
<menuitem value="New" onclick="CreateNewDoc()" />
<menuitem value="Open" onclick="OpenDoc()" />
<menuitem value="Close" onclick="CloseDoc()" />
</popup>
</menu>

Imports:
<menu id="file" value="File"> <popup> <menuitem value="New"
onclick="CreateNewDoc()" /> <menuitem value="Open"
onclick="OpenDoc()" /> <menuitem value="Close"
onclick="CloseDoc()" /> </popup></menu>

Thanks for your helpl.
-WDB


On May 16, 9:46 am, Scott Hernandez <scotthernan...@gmail.com> wrote:
> Can you post a sample to gist/pastie so we can test it?
> On May 16, 2012 9:26 AM, "WDB" <walter.breidenst...@thomsonreuters.com>

Nat

unread,
May 16, 2012, 10:17:36 AM5/16/12
to mongod...@googlegroups.com
Your data doesn't look like JSON. Are you sure that's what you import? Also note that mongoimport takes one document per line as an input. 
> > mongodb-user+unsubscribe@googlegroups.com

WDB

unread,
May 16, 2012, 10:24:27 AM5/16/12
to mongodb-user
Oops. Yeah, that was the XML version.

This is what won't load:

{"menu": {
"id": "file",
"popup": {"menuitem": [
{
"value": "New",
"onclick": "CreateNewDoc()"
},
{
"value": "Open",
"onclick": "OpenDoc()"
},
{
"value": "Close",
"onclick": "CloseDoc()"
}
]},
"value": "File"
}}

Mind you, NOTHING is loading for me, unless I remove the line control
chars.

Here's my line command:
mongoimport --collection bddocs --file c:\data\JSON\output
\example1.json

-WDB
> > > > mongodb-user...@googlegroups.com

Nat Luengnaruemitchai

unread,
May 16, 2012, 12:22:41 PM5/16/12
to mongod...@googlegroups.com
As I said, mongoimport expects one json document to be in one line (i.e. it uses new line as document separator)

WDB

unread,
May 16, 2012, 2:13:18 PM5/16/12
to mongodb-user
OK. I get that, now. One document, one line. And guess what? I'm fine
with that!
I'm using JSONObject from JSON.org to convert XML, and there is an
INDENT_FACTOR argument, which, when set to zero, causes no output of
line feeds. So I'm good. Thanks again for your feedback.

On May 16, 12:22 pm, Nat Luengnaruemitchai <nat.lu...@gmail.com>
wrote:
Reply all
Reply to author
Forward
0 new messages