I'm trying to insert Query in mongoDB, using Studio 3T, but keep getting this error

7k Views Asked by At
{
    "_id" : ObjectId("5c139771d79ac8eac11e754a"),
    "title" : "API",
    "content" : "API stands for Application Programming Interface. It is a set of subroutine definitions, communication protocols, and tools for building software. In general terms, it is a set of clearly defined methods of communication among various components. A good API makes it easier to develop a computer program by providing all the building blocks, which are then put together by the programmer."
} 
{
    "_id" : ObjectId("5c1398aad79ac8eac11e7561"),
    "title" : "Bootstrap",
    "content" : "This is a framework developed by Twitter that contains pre-made front-end templates for web design"
} 
{
    "_id" : ObjectId("5c1398ecd79ac8eac11e7567"),
    "title" : "DOM",
    "content" : "The Document Object Model is like an API for interacting with our HTML"
}

This is the error i get :- JSON parsing error: Orphan character detected at line 1, col 471

14

There are 14 best solutions below

0
On

I was trying to add collections and was exporting via Studio3T and importing but it didn't work. Got an error that said

You must correct the following issues before proceeding:

At least one collection must be included into the import

Anyways, what worked for me was instead of importing all the collections at once (there were many collections in the exported folder), I exported and imported the collections one by one (only one collection at a time in the exported folder). Don't know why that worked.

0
On

Try copying and pasting the three documents into Studio 3T and they will import. The Insert Document (singular) option is for inserting a single document.

0
On

As counterintuitive as it may be, it seems that you can batch import documents into Studio 3T by simply:

copy your JSON format e.g.:

{
    "_id": "6287bd6de87a8d4bc4f76264",
    "title": "REST",
    "content": "REST is short for Representational State Transfer, it is an architectural style for designing APIs."
},
{
    "_id": "6287be09e87a8d4bc4f76267",
    "title": "Bootstrap",
    "content": "This is a framework developed by Twitter that contains pre-made front-end templates for web design"
},
{
    "_id": "6287be40e87a8d4bc4f76268",
    "title": "DOM",
    "content": "The Document Object Model is like an API for interracting with our HTML."
},
{
    "_id": "6287bf3ce87a8d4bc4f76269",
    "title": "API",
    "content": "API stands for Application Programming Interface. It is a set of subroutine definitions, communication protocols, and tools for building software. In general terms, it is a set of clearly defined methods of communication among various components. A good API makes it easier to develop a computer program by providing all the building blocks, which are then put together by the programmer."
}

Left click anywhere on the results tab of your articles and paste. a dialogue will appear asking if you want to import results from clipborad. If you confirm and refresh the tab all your data should be there. Albert

0
On

Add one documents at a time. Not all at the same time.

It did the same thing for me when i added the 3 documents all at once (following Angela from App Brewery in Udemy course) but I figured that we need to add the 3 documents one at a time, meaning: Click on the add document icon and paste the first document and save. Click on add document again and then add the second and did the same for the last document.

0
On

Copy your JSON then right-click inside your collection tab and select "Paste doucments" and hit ok then refresh. It will receive all the documents. It's kind of like InsertMany.

enter image description here

0
On

You can try running this script to add all data into database once

db.articles.insertMany([
{
    "_id" : "5c18e1892998bdb3b3d355bf",
    "title" : "REST",
    "content" : "REST is short for REpresentational State Transfer. IIt's an architectural style for designing APIs."
}
,

{
    "_id" : ObjectId("5c139771d79ac8eac11e754a"),
    "title" : "API",
    "content" : "API stands for Application Programming Interface. It is a set of subroutine definitions, communication protocols, and tools for building software. In general terms, it is a set of clearly defined methods of communication among various components. A good API makes it easier to develop a computer program by providing all the building blocks, which are then put together by the programmer."
}
,

{
    "_id" : ObjectId("5c1398aad79ac8eac11e7561"),
    "title" : "Bootstrap",
    "content" : "This is a framework developed by Twitter that contains pre-made front-end templates for web design"
}
,

{
    "_id" : ObjectId("5c1398ecd79ac8eac11e7567"),
    "title" : "DOM",
    "content" : "The Document Object Model is like an API for interacting with our HTML"
}

,
{
    "_id" : "5c18f35cde40ab6cc551cd60",
    "title" : "Jack Bauer",
    "content" : "Jack Bauer once stepped into quicksand. The quicksand couldn't escape and nearly drowned.",
    "__v" : 0
}
])
0
On

Well, you probably already figured out everything , but for people who came here as i did, steps are following:

  1. Right-click on articles collection in popped menu choose Open Collection tab. You should see articles tab with Query, Projection, etc and one more tab below with sub-tabs: Result, Query Code, Explain

  2. Copy all objects which you want to insert into your collections.

  3. By default you should have Result sub-tab open with textfield. Right click anywhere on text-field and choose Paste Document(s).

  4. In pop-up window, you will be asked: "Import docs from clipboard?". Choose Ok.

  5. In order to refresh page push "refresh" looking sign right under Result sub-tab.

0
On

Try adding the document one after another, everytime you need to insert a document click add document and insert a single document. It works for me

1
On

may be we can add one by one , that won't give any errors

0
On

Found a way around. Right click and select IMPORT > JSON, then select PASTE FROM CLIPBOARD, it will paste your sample code there. Then press RUN button in the Schedule, Load Task tab. It will add those codes/articles to your articles collection.

Here is the import option

1
On

Use this it will worked

[
    {
        "_id": "6287bd6de87a8d4bc4f76264",
        "title": "REST",
        "content": "REST is short for Representational State Transfer, it is an architectural style for designing APIs."
    },
    {
        "_id": "6287be09e87a8d4bc4f76267",
        "title": "Bootstrap",
        "content": "This is a framework developed by Twitter that contains pre-made front-end templates for web design"
    },
    {
        "_id": "6287be40e87a8d4bc4f76268",
        "title": "DOM",
        "content": "The Document Object Model is like an API for interacting with our HTML."
    },
    {
        "_id": "6287bf3ce87a8d4bc4f76269",
        "title": "API",
        "content": "API stands for Application Programming Interface. It is a set of subroutine definitions, communication protocols, and tools for building software. In general terms, it is a set of clearly defined methods of communication among various components. A good API makes it easier to develop a computer program by providing all the building blocks, which are then put together by the programmer."
    }
]
0
On
  1. right click on the collection name, (in left side connection list)
  2. click on Add/Edit validator, set validation level to 'OFF' in the prompted window and click save.
  3. right click anywhere in Find query prompt, and select documents, click on insert document, and copy one by one, click add.
0
On

This is for the Angela YeU course, You have to import them one after the other.

0
On

Add your Documents ONE by ONE , and make sure you have no typos:
Look at the image here.

Studio 3T:
Studio 3T