添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement . We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account
  • I have completed all Troubleshooting Steps .
  • I'm on the latest version of Directus .
  • There's no other issue that already describes my problem.
  • Describe the Bug

    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.

    Hi @joselcvarela

    Thank you so much for your prompt response.

    As advised, I've upgraded it to the latest version, but still no luck.

    Feel free to check this loom: https://www.loom.com/share/68d885807b1344019726ffa7476259df

    Thanks.

    Are there any spaces or newlines we're not seeing in the screenshots?

    According to the Postgres docs, a plain string should be valid JSON:

    https://www.postgresql.org/docs/13/datatype-json.html

    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? :-)