The following on PostgresSQL 9.2:
CREATE TABLE test (j JSON, ja JSON[]); INSERT INTO test (j) VALUES('{"name":"Alex", "age":20}' );
The first insert works fine. The second insert returns an error: the column "ja" is of type json [], but the expression is of type text []
I can use type to prevent error:
INSERT INTO test(ja) VALUES( CAST (ARRAY['{"name":"Alex", "age":20}', '{"name":"Peter", "age":24}'] as JSON[]) );
My question is, is there a way to avoid casting?
source share