skip to Main Content

In Studio 3T i have created the collection in which i am adding a document after which popup window appears Titled >>Insert JSON Document<< to add the data in the document then i wrote these items.

{
    "_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
}

after that when i click the button add document, another popup appears which is Titled >>JSON Validation<< under which "Orphan character detected at line 8, col 1" shows. And i am not able to insert these documents at once.

How could i insert all these object at once in the document ?

7

Answers


  1. It’s a limitation, unsupported till the date. You could run a insertMany query

     db.collection.insertMany([{doc1}, {doc2}])
    

    Github link

    Alternatively you can import documents if you don’t want to run a direct query.

    Login or Signup to reply.
  2. Copy your JSON documents to the clipboard, then go to your collection and Control/Command V to paste the clipboard into the collection. You’ll be prompted "Import documents from clipboard" – click OK and when done, refresh your view to see the newly imported documents.

    Background: The Insert JSON Document, is, as it says, for single JSON documents. The error you see is because it is detecting a second JSON document beginning. Multiple JSON Document insertion is better handled by import, and if you paste JSON documents into a collection, it automatically triggers an import from clipboard.

    Login or Signup to reply.
  3. I also faced with same issue when I was trying to insert multiple objects at once. My solution was to add the objects individually. It know it takes time but I could not find any other way to do it.

    Login or Signup to reply.
  4. It’s easy. Select all the JSON data that you want to enter into the collections, and Copy it to the clipboard (Ctrl+C on PC, or Command+C on MAC).

    1. In Studio3T right click on the document where you want to insert items.
    2. From the menu choose "Import Data…"
    3. Leave the first option pre-selected "JSON – Mongo shell …"
    4. Confirm the selection by clicking "Configure"
    5. Click on "Paste from clipboard" and click on the green "run" button.

    That’s it 🙂 and it works as of Oct 2, 2022.

    Login or Signup to reply.
  5. In the document window:
    Right click > Paste Document(s) or simply CTRL + V

    that will insert all the documents you have copied.

    Login or Signup to reply.
    1. create json file and add your data in it.
    [
      {
        "title": "REST",
        "content": "REST is short for REpresentational State Transfer. It's an architectural style for designing APIs."
      },
      {
        "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."
      },
      {
        "title": "Bootstrap",
        "content": "This is a framework developed by Twitter that contains pre-made front-end templates for web design"
      },
      {
        "title": "DOM",
        "content": "The Document Object Model is like an API for interacting with our HTML"
      },
      {
        "title": "Jack Bauer",
        "content": "Jack Bauer once stepped into quicksand.The quicksand couldn't escape and nearly drowned."
      }
    ]
    
    1. In studio 3T, right click on your document and select import data
      as given here

    2. select JSON

    3. click on add source and add your json file.

    4. click on RUN to add your data.

    Login or Signup to reply.
  6. Select the JSON data you want to enter into the collections, and Copy it to the clipboard. (Ctrl + V or Command + V)
    then in the new Studio 3t, first of all select your collection to view
    then click on Edit in the file menu, and then select Paste Documents,
    click Ok and then refresh your documents

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search