How could I extract nested json using sqlite json-extract or other sqlite json command ?
Here I'd like to extract given_id
"invoices": [{
........
    "items": [{
    "given_id": "TBC0003B",
    ...
        }
    ]
   }
]
Thanks.
How could I extract nested json using sqlite json-extract or other sqlite json command ?
Here I'd like to extract given_id
"invoices": [{
........
    "items": [{
    "given_id": "TBC0003B",
    ...
        }
    ]
   }
]
Thanks.
In SQLite you can use json_extract() as follows:
select json_extract(my_json_col, '$.invoices[0].items[0].given_id') my_given_id from mytable
This gives you the given_id attribute of the first element of the items array under first element of the invoices array.
with mytable as (select '{
    "invoices": [{
        "items": [{ "given_id": "TBC0003B" }] 
    }]
}' my_json_col)
select json_extract(my_json_col, '$.invoices[0].items[0].given_id') my_given_id from mytable
| my_given_id | | :---------- | | TBC0003B |
