mbdavid / LiteDB.Studio

A GUI tool for viewing and editing documents for LiteDB v5
MIT License
750 stars 197 forks source link

Import from Json: Unexpected token `{` #60

Open rrirower opened 2 years ago

rrirower commented 2 years ago

Admittedly, I am new to both noSQL and LiteDB. I've downloaded the Studio and have been playing around with it to become familiar with the concepts. However, when I try to import a JSON file, I get an error:

Unexpected token `{` in position 0.

SELECT $   INTO
^

The file is very simple and is something I found in a noSQL article. It consists of:

{
  "Contact": [
    {
      "_id": 1,
      "FullName": "Lucy",
      "Email": "lucy@gmail.com",
      "Phone": "4584656970",
      "Address": "223 Str"
    },
    {
      "_id": 2,
      "FullName": "Tom",
      "Email": "tom@gmail.com",
      "Phone": "4375588889",
      "Address": "123 Str"
    }
  ]
}

Since there's no wiki or help file, I'm looking for guidance on how to use this tool. I think LiteDB is just what I want for my project. I'd like to store some JSON data in a database.

rrirower commented 2 years ago

Is anyone available to help?

Rufistofeles commented 1 year ago

Hi, there... You can try with a json like this: [ { "_id": 1, "FullName": "Lucy", "Email": "lucy@gmail.com", "Phone": "4584656970", "Address": "223 Str" }, { "_id": 2, "FullName": "Tom", "Email": "tom@gmail.com", "Phone": "4375588889", "Address": "123 Str" } ]

And the query should be like this:

SELECT $
  INTO Contact
  FROM $file('C:/SOME_FOLDER/file.json');