Skip to content

process nested json #837

Answered by lovasoa
setop asked this question in Q&A
Discussion options

You must be logged in to vote

Here is an example of how to do it in SQLite

-- Create the People table
CREATE TABLE IF NOT EXISTS People (
    id INTEGER PRIMARY KEY,
    name TEXT
);

-- Create the Addresses table
CREATE TABLE IF NOT EXISTS Addresses (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    person_id INTEGER,
    street TEXT,
    city TEXT,
    state TEXT,
    zip TEXT,
    FOREIGN KEY (person_id) REFERENCES People(id)
);

SET people = json('{"people": [
   {"id": 23469, "name": "Charlie Brown", "addresses": [
        {"street": "321 Birch St", "city": "Madison", "state": "WI", "zip": "53703"},
        {"street": "654 Cedar St", "city": "Madison", "state": "WI", "zip": "53704"}
  ]}
]}');

-- Insert data from J…

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by setop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants