SQLite Forum

Storing invalid JSON (integer-based keys)?
Login
Hi there. I am using an [ORM for SQLite](http://docs.peewee-orm.com/en/latest/peewee/sqlite_ext.html#JSONField) that makes use of the [json1 extension](https://sqlite.org/json1.html) to implement a JSONField() attribute on tables.

```
sqlite> select json_valid('{1: "k1"}');
0
sqlite> select json_valid('{"1": "k1"}');
1
```

I forgot that integer-based keys are not valid JSON. It turns out that I can store this invalid JSON. But when I try to fetch it, sometimes it returns as integer keys `0, 1, 2` and sometimes it returns string keys `'0', '1', '2'`.

Should attempting to store this invalid JSON (integer-based keys) result in an error?