Home > database >  MongoDB giving error while importing JSON file
MongoDB giving error while importing JSON file

Time:04-27

I am trying to import my json file to mongodb.I think there is no error such ass "missing { symbol" but mongodb always giving error. What should i do to pass it.I found a sample and edited like it.But still same result.I put " symbol to all variables. This is my JSON file

[
{
    "name":"Bol Peynirli",
    "varients":[
       "small", 
       "medium", 
       "large"
],
    "prices":[
       {
          "small":53.99,
          "medium":61.99,
          "large":101.99
       }
],
    "category":"pizzalar",
    "image":"https://www.dwfdzxoxxagos.cloudfront.net/images/products/web_detay_4_peynirli.jpg",
    "description":"4x4 PEYNİRLİ",
},
  {
    "name":"Bol Bol",
    "varients":[
       "small", 
       "medium", 
       "large"
    ],
    "prices":[
       {
          "small": 49.9,
          "medium": 57.99,
          "large": 97.99
       }
    ],
    "category": "Pizza",
    "image": "https://dwfdzxoxxagos.cloudfront.net/"image"s/products/web_detay_bolbol.jpg",
    "description":
      "Pizza Sosu, Mozarella Peyniri, Dilim Sucuk, Küp Sucuk, Soğan, Yeşil Biber, Mantar, Siyah Zeytin, Mısır, Şerit Sosis, Kırmızı Közleme Biber, Susam",
  },
  {
    "name": "Kaburgalı",
    "varients": ["small", "medium", "large"],
    "prices": [
      {
        "small": 53.99,
        "medium": 61.99
      }
    ],
    "category": "Pizza",
    "description":
      "Barbekü Sos, Mozarella Peyniri, Fırınlanmış Patlıcan, Füme Kaburga, Soğan, Mantar, Susam, Kekik",
    "image": "https://dwfdzxoxxagos.cloudfront.net/"image"s/products/web_detay_kaburgali.jpg",
  },
  {
    "name": "Margarita",
    "varients": ["small", "medium", "large"],
    "prices": [
      {
        "small": 41.99,
        "medium": 49.99,
        "large": 89.99
      }
    ],
    "category": "Pizza",
    "image": "https://dwfdzxoxxagos.cloudfront.net/"image"s/products/web_detay_margarita.jpg",
    "description":
      "Pizza Sosu, Mozarella Peyniri, Domates",
  },
  {
    "name": "Süper Sucuklu",
    "varients": ["small", "medium", "large"],
    "prices": [
      {
        "small": 49.99,
        "medium": 57.99,
        "large": 97.99
      }
    ],
    "category": "Pizza",
    "image":"https://dwfdzxoxxagos.cloudfront.net/images/products/0_y_supersucuklu.jpg",
    "description":
      "Pizza Sosu, Mozarella Peyniri, Küp Sucuk, Siyah Zeytin, Mantar, Kırmızı Köz Biber, Kekik",
  },
  {
    "name": "v",
    "varients": ["small", "medium", "large"],
    "prices": [
      {
        "small": 45.99,
        "medium": 53.99
      }
    ],
    "category": "Pizza",
    "image": "https://dwfdzxoxxagos.cloudfront.net/"image"s/products/web_detay_patsos.jpg",
    "description":
      "Mozarella Peyniri, Pizza Sosu, Parmak Patates, Şerit Sosis",
  },
];

So it gives error like enter image description here

CodePudding user response:

You have an embedded double quote in a few of your image properties of the JSON object. You also have commas that shouldn't be right before the ending } in the JSON.

Remove the double quotes and the misplaced commas, and it will validate.

[
   {
      "name":"Bol Peynirli",
      "varients":[
         "small",
         "medium",
         "large"
      ],
      "prices":[
         {
            "small":53.99,
            "medium":61.99,
            "large":101.99
         }
      ],
      "category":"pizzalar",
      "image":"https://www.dwfdzxoxxagos.cloudfront.net/images/products/web_detay_4_peynirli.jpg",
      "description":"4x4 PEYNİRLİ"
   },
   {
      "name":"Bol Bol",
      "varients":[
         "small",
         "medium",
         "large"
      ],
      "prices":[
         {
            "small":49.9,
            "medium":57.99,
            "large":97.99
         }
      ],
      "category":"Pizza",
      "image":"https://dwfdzxoxxagos.cloudfront.net/images/products/web_detay_bolbol.jpg",
      "description":"Pizza Sosu, Mozarella Peyniri, Dilim Sucuk, Küp Sucuk, Soğan, Yeşil Biber, Mantar, Siyah Zeytin, Mısır, Şerit Sosis, Kırmızı Közleme Biber, Susam"
   },
   {
      "name":"Kaburgalı",
      "varients":[
         "small",
         "medium",
         "large"
      ],
      "prices":[
         {
            "small":53.99,
            "medium":61.99
         }
      ],
      "category":"Pizza",
      "description":"Barbekü Sos, Mozarella Peyniri, Fırınlanmış Patlıcan, Füme Kaburga, Soğan, Mantar, Susam, Kekik",
      "image":"https://dwfdzxoxxagos.cloudfront.net/images/products/web_detay_kaburgali.jpg"
   },
   {
      "name":"Margarita",
      "varients":[
         "small",
         "medium",
         "large"
      ],
      "prices":[
         {
            "small":41.99,
            "medium":49.99,
            "large":89.99
         }
      ],
      "category":"Pizza",
      "image":"https://dwfdzxoxxagos.cloudfront.net/images/products/web_detay_margarita.jpg",
      "description":"Pizza Sosu, Mozarella Peyniri, Domates"
   },
   {
      "name":"Süper Sucuklu",
      "varients":[
         "small",
         "medium",
         "large"
      ],
      "prices":[
         {
            "small":49.99,
            "medium":57.99,
            "large":97.99
         }
      ],
      "category":"Pizza",
      "image":"https://dwfdzxoxxagos.cloudfront.net/images/products/0_y_supersucuklu.jpg",
      "description":"Pizza Sosu, Mozarella Peyniri, Küp Sucuk, Siyah Zeytin, Mantar, Kırmızı Köz Biber, Kekik"
   },
   {
      "name":"v",
      "varients":[
         "small",
         "medium",
         "large"
      ],
      "prices":[
         {
            "small":45.99,
            "medium":53.99
         }
      ],
      "category":"Pizza",
      "image":"https://dwfdzxoxxagos.cloudfront.net/images/products/web_detay_patsos.jpg",
      "description":"Mozarella Peyniri, Pizza Sosu, Parmak Patates, Şerit Sosis"
   }
]

  • Related