sqliteHow can I use SQLite to store and query JSON data?
SQLite can be used to store and query JSON data with the JSON1 extension. The extension provides a set of SQL functions for storing and querying JSON data.
For example, the following code block uses the json_insert()
function to insert a JSON document into a table:
CREATE TABLE test_table (id INTEGER PRIMARY KEY, doc JSON);
INSERT INTO test_table (doc) VALUES (json_insert('{"name": "John Doe"}'));
The following code block uses the json_extract()
function to query the JSON document stored in the table:
SELECT json_extract(doc, '$.name') FROM test_table;
Output example
John Doe
The JSON1 extension provides a range of functions for manipulating and querying JSON data, including json_extract()
, json_insert()
, json_replace()
, json_set()
, and json_remove()
. For more information, see the SQLite JSON1 documentation.
More of Sqlite
- How do I use SQLite triggers in my software development project?
- How do I use regular expressions to query a SQLite database?
- How do I store a timestamp in an SQLite database?
- How can I use SQLite with Rust?
- How do I read a SQLite query plan?
- How do I set up an autoincrement primary key in SQLite?
- How do I set up an ODBC driver to connect to an SQLite database?
- How to configure SQLite with XAMPP on Windows?
- How do I resolve an error "no such column" when using SQLite?
- How can I use SQLite with Maui?
See more codes...