Answer the question
In order to leave comments, you need to log in
What is the correct way to use json in PostgreSQL?
Hello, I've run into a problem.
Not so long ago, postgres has support for json data, and I'm trying to use it. But I missed something ..
There is a request, in 2 tables, in one of which there is a json field.
SELECT*
FROM "profile"
INNER JOIN "util_template" ON ( "profile"."template_id" = "util_template"."id" )
WHERE ("profile"."member_id" = 3 AND "profile"."company_id" = 1
AND (((util_template.list_actions)::json ->'OwnerVehicleViewSet')->>'create') IS NOT NULL )
ERROR: invalid input syntax for type json
SQL-состояние: 22P02
Подробности: Expected "," or "]", but found ":".
Контекст: JSON data, line 1: {"OwnerVehicleViewSet":["post":...
((util_roletemplate.list_actions)::json -> "OwnerVehicleViewSet")->>"create")
ERROR: column "OwnerVehicleViewSet" does not exist
LINE 13: AND (((util_roletemplate.list_actions)::json -> "OwnerVehicl...
Answer the question
In order to leave comments, you need to log in
The problem was in the data in the database, a charfield format data column, and of course I wrote incorrect json there. Everything crashed when trying to parse the json from the database.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question