In my model I have the following field –
data_fields = ArrayField(models.JSONField(null=True, blank=True), blank=True, null=True)
In order to test this out, I entered the following in the data_field in the django admin –
[{"key": "name", "label": "Name"}, {"key": "amount", "label": "Amount"}]
But I get an error saying
Item 1 in the array did not validate: Enter a valid JSON.
Item 2 in the array did not validate: Enter a valid JSON.
Item 3 in the array did not validate: Enter a valid JSON.
Item 4 in the array did not validate: Enter a valid JSON.
I only get this error if there are multiple key-value pairs in the JSON. If there is only one JSON element with one key-value pair, it works. If there are multiple elements in the array, or there are multiple key-value pairs in the JSON field, I get the error above.
Why is this happening, and how do I fix it?
1