Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import from Json: Unexpected token { #60

Open
rrirower opened this issue Sep 27, 2021 · 2 comments
Open

Import from Json: Unexpected token { #60

rrirower opened this issue Sep 27, 2021 · 2 comments

Comments

@rrirower
Copy link

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": "[email protected]",
      "Phone": "4584656970",
      "Address": "223 Str"
    },
    {
      "_id": 2,
      "FullName": "Tom",
      "Email": "[email protected]",
      "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
Copy link
Author

rrirower commented Oct 5, 2021

Is anyone available to help?

@Rufistofeles
Copy link

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

And the query should be like this:

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants