JSON Schema validation in PostgreSQL?

There is another PostgreSQL extension that implements json validation. The usage is almost the same as “Postgres-JSON-schema” CREATE TABLE example (id serial PRIMARY KEY, data jsonb); — do is_jsonb_valid instead of validate_json_schema ALTER TABLE example ADD CONSTRAINT data_is_valid CHECK (is_jsonb_valid(‘{“type”: “object”}’, data)); INSERT INTO example (data) VALUES (‘{}’); — INSERT 0 1 INSERT INTO example … Read more

How do I modify fields inside the new PostgreSQL JSON datatype?

Update: With PostgreSQL 9.5, there are some jsonb manipulation functionality within PostgreSQL itself (but none for json; casts are required to manipulate json values). Merging 2 (or more) JSON objects (or concatenating arrays): SELECT jsonb ‘{“a”:1}’ || jsonb ‘{“b”:2}’, — will yield jsonb ‘{“a”:1,”b”:2}’ jsonb ‘[“a”,1]’ || jsonb ‘[“b”,2]’ — will yield jsonb ‘[“a”,1,”b”,2]’ So, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)