SQLite Forum

json_append array with multiple values
Login
Hello,

I currently have a table with a column of json data. One element of the JSON is an array which determines the 'capacity' for something used by an application. Example:

```json
{
  id: 3,
  items: {
    category: "foo",
    items: [
      {
        "type": 1,
        "amount": 1
      },
      null,
      null,
      null,
      null
    ]
  }
}
```

My intention is to increase that capacity (5 -> 10) by appending a series of "null" values to that array.

I can append a single value with `json_insert`:

```sql
SELECT json_insert((SELECT items from example), '$[' || json_array_length(items) || ']', json("null")) from example;
```

I can append an array of elements via `json("[null, null, null]"))`, but it becomes nested:

```json
  null,
  null,
  null,
  [
    null,
    null,
    null
  ]
```

Is there a way to append several individual null items to the end of this array? Or otherwise 'flatten' the nested result.

Thank you