SQLite Forum

Storing invalid JSON (integer-based keys)?
Login
There is no such thing as a JSON type.  JSON is just a text string.  If you want to be sure that your TEXT is valid JSON then you will have to CHECK that it is valid JSON, just like a date/time/datetime is just a text string and if you want to make sure that the TEXT is a valid date/time/datetime text string, you need to check that it is valid.

<https://sqlite.org/datatype3.html>

```
create table t
(
   id integer primary key,
   json text check (json IS null or json_valid(json))
   dt text check (datetime(dt, '+0 days') IS dt)
);
```

would prevent you from inserting text that is not valid json into a text field or a datetime that is not a datetime.  Otherwise you can pretty much put whatever you like wherever your little heart desires to put it (with very few restrictions) without resulting in an error.