I'm trying to insert an array of JSON values into a postgres database. But I'm getting this error:
error: malformed array literal: "{{"traits":{"belief":[],"personality":[],"physical":[]},"relationships":[]},{"traits":{"belief":[],"personality":[],"physical":[]},"relationships":[]}}"
If I'm correct, the array literal should take the form "{{...},{...}}". As far as I know, this is the correct way to insert an array of JSON elements into a postgres table.
Here's my whole query if it helps:
INSERT INTO main(prev_snippets, next_snippets, req_characters, description, requirements, prereq_events, character_effects, world_effects, character_decisions)
VALUES ('{"22","45","99"}', '{"33","22"}', '{{"traits":{"belief":[],"personality":[],"physical":[]},"relationships":[]},{"traits":{"belief":[],"personality":[],"physical":[]},"relationships":[]}}', 'cvdfgfg', NULL, NULL, NULL, NULL, NULL);
prev_snippets and next_snippets are arrays of integers (I'll make those integers instead of strings when I get the JSON problem figured out), req_characters is a JSONB array, and description is text.
Please let me know how I can make my question better. Thanks a ton for the help.
Update:
Here's the table definition:
CREATE TABLE main (
id SERIAL NOT NULL UNIQUE,
PRIMARY KEY(id),
prev_snippets INTEGER[],
next_snippets INTEGER[],
req_characters JSONB[],
description TEXT NOT NULL,
requirements JSONB[],
prereq_events JSONB[],
character_effects JSONB[],
world_effects JSONB[],
character_decisions JSONB[]
);
I believe I'm using postgres version 14.