Data Import
JSON Format Settings
If the JSON file contains JSON that is not newline-delimited or an array, `unstructured` may be used.
To demonstrate its use, we use the example file [`unstructured.json`](https://duckdb.org/data/unstructured.json):  
```json
{
"key1":"value1",
"key2":"value1"
}
{
"key1":"value2",
"key2":"value2"
}
{
"key1":"value3",
"key2":"value3"
}
```  
```sql
SELECT *
FROM read_json('unstructured.json', format = 'unstructured');
```  
<div class="narrow_table monospace_table"></div>  
|  key1  |  key2  |
|--------|--------|
| value1 | value1 |
| value2 | value2 |
| value3 | value3 |  
#### Records Settings {#docs:data:json:format_settings::records-settings}  
The JSON extension can attempt to determine whether a JSON file contains records when setting `records = auto`.
When `records = true`, the JSON extension expects JSON objects, and will unpack the fields of JSON objects into individual columns.  
Continuing with the same example file, [`records.json`](https://duckdb.org/data/records.json):  
```json
{"key1":"value1", "key2": "value1"}
{"key1":"value2", "key2": "value2"}
{"key1":"value3", "key2": "value3"}
```  
```sql
SELECT *
FROM read_json('records.json', records = true);
```  
<div class="narrow_table monospace_table"></div>  
|  key1  |  key2  |
|--------|--------|
| value1 | value1 |
| value2 | value2 |
| value3 | value3 |  
When `records = false`, the JSON extension will not unpack the top-level objects, and create `STRUCT`s instead:  
```sql
SELECT *
FROM read_json('records.json', records = false);
```  
<div class="narrow_table monospace_table"></div>  
|               json               |
|----------------------------------|
| {'key1': value1, 'key2': value1} |
| {'key1': value2, 'key2': value2} |
| {'key1': value3, 'key2': value3} |  
This is especially useful if we have non-object JSON, for example, [`arrays.json`](https://duckdb.org/data/arrays.json):  
```json
[1, 2, 3]
[4, 5, 6]
[7, 8, 9]
```  
```sql
SELECT *
FROM read_json('arrays.json', records = false);
```  
<div class="narrow_table monospace_table"></div>  
|   json    |
|-----------|
| [1, 2, 3] |
| [4, 5, 6] |
| [7, 8, 9] |