With this table
CREATE TABLE IF NOT EXISTS actions (
action_id UUID NOT NULL DEFAULT uuid_generate_v4(),
inputs JSONB[] NOT NULL DEFAULT ARRAY[]::JSONB[]
)
I'm trying to insert this data
INSERT INTO actions (
action_id,
inputs
)
VALUES (
'41fc94af-2f4e-424f-acde-641bb63f4b82',
array['{"type":"string"}{"displayName":"Base OAuth URL","type":"string","description":"Base OAuth URL"}']::jsonb[]
);
But getting the error
ERROR: invalid input syntax for type json
LINE 7: array['{"type":"string"}{"di...
^
DETAIL: Expected end of input, but found "{".
CONTEXT: JSON data, line 1: {"type":"string"}{...
This also doesn't work
INSERT INTO actions (
action_id,
inputs
)
VALUES (
'41fc94af-2f4e-424f-acde-641bb63f4b82',
[{"type":"string"}{"displayName":"Base OAuth URL","type":"string","description":"Base OAuth URL"}]::jsonb[]
);
CodePudding user response:
I didn't get you intentionr. For sure what you wrote inside array[..]
is neither a single json nor an array of json.
If {"type":"string"}
and {"displayName":"Base OAuth URL","type":"string","description":"Base OAuth URL"}
are two different objects then you have to write:
array[
'{"type":"string"}',
'{"displayName":"Base OAuth URL","type":"string","description":"Base OAuth URL"}'
]::jsonb[]