You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
The collection interface does not allow storing
strings
to a
JSON
field and raises the following error:
However, it allows storing other types of values including the
number
,
boolean
, and
null
, but only
arrays
and
objects
are being displayed in the edit field after the modification is saved.
To Reproduce
Create a collection field with the following settings:
Type:
JSON
Interface:
Code
Display:
Formatted JSON value
Errors Shown
Unexpected Error: invalid input syntax for type json
What version of Directus are you using?
9.2.1
What version of Node.js are you using?
I'm using the containerized Directus
What database are you using?
PostgreSQL 10, PostgreSQL 14
What browser are you using?
Chrome
What operating system are you using?
Windows, macOS
How are you deploying Directus?
Docker
Hey
@AnmSaiful
Try to update your Directus instance to latest.
Also try to remove double quotes.
As of right now I am not able to reproduce the issue. Try the steps above and let us know if that worked.
Unexpected Error: invalid input syntax for type json
Editing JSON field with string throws "invalid input syntax for type json"
Jan 17, 2022
Odd, I can verify the issue now. It happens when editing an existing item. But on create it works fine. I already updated the title 👍
I tested with
Raw Value
and
by setting
aaaa
it converts to null on App
by setting
"aaaa"
(double quotes) it throws the error OP mentioned
@rijkvanzanten
it works if I update the data directly in the database using a SQL query. So, I think the issue is raised in the Directus end.
@joselcvarela
I populated the initial value programmatically, so I did not check with a new value, but yes, I was trying to update a value and got the error. I think both the frontend and backend have issues to be resolved.
By the way, am I talking with the coolest Directus engineers? :-)