Convert a JSON file to an SQLite database right from VSCode!
Install in VSCode.
- Open your VSCode project.
- Right-click a JSON file such as
example.json. - Select the context menu Convert JSON to SQLite.
- A new file
example.sqlitewill be saved in the same directory. The database table name is the same as the filename example.
To preview an SQLite file contents:
- Right-click a SQLite file such as
example.sqlite. - Select the context menu Preview SQLite File.
- A message will display showing the top 3 records in the database.
To change the name of the table saved in the sqlite file, use the following steps.
- In VSCode, select File->Preferences->Settings.
- Search for json-to-sqlite.
- Enter a value for Custom Table Name.
- Uncheck the option Use Filename As Table Name.
- Convert any JSON file to SQLite.
- Right-click a JSON file or use the command pallete Ctrl-Shift-P->Convert JSON to SQLite and choose a file.
- Preview SQLite file contents.
- Customize the table name stored in sqlite.
The following JSON file formats are supported for conversion to SQLite:
This results in a single table with the name of the JSON file or as configured in settings.
[
{
"id": 1,
"first_name": "Loella",
"last_name": "Albers"
},
{
"id": 2,
"first_name": "Laurie",
"last_name": "Strongman"
}
]This results in a single table with the name "locations".
{
"locations": [
{
"id": 0,
"name": "Acme Fresh Start Housing",
"city": "Chicago",
"state": "IL"
},
{
"id": 1,
"name": "A113 Transitional Housing",
"city": "Santa Monica",
"state": "CA"
}
]
}This results in two tables with the names "table1" and "table2".
[
{
"table1": [
{
"id": 0,
"name": "Acme Fresh Start Housing",
"city": "Chicago",
"state": "IL"
},
{
"id": 1,
"name": "A113 Transitional Housing",
"city": "Santa Monica",
"state": "CA"
}
]
},
{
"table2": [
{
"id": 0,
"name": "Acme Fresh Start Housing",
"city": "Chicago",
"state": "IL"
},
{
"id": 1,
"name": "A113 Transitional Housing",
"city": "Santa Monica",
"state": "CA"
}
]
}
]To deploy and publish the extension, use the following steps.
- Open a VS Code terminal window and use the command:
vsce package - In VS Code, open the Extensions tab and click '...' in the top-right and choose Install from VSIX.
- Select to install the newly packaged .vsix file created in step 1.
- Test the extension.
- Upload the package to the marketplace.
MIT
Kory Becker http://www.primaryobjects.com/kory-becker
