How can I verify in Postgresql that JSON is valid?
问题 I've got a big database with analytics data written in JSON. I want to filter out rows with incorrect data: invalid json (some rows has something like that: '{"hello": "world' some attributes is not array so it would take '{"products": [1,2,3]}' and will leave out the '{"products": 1}' I want to do something like that: select * from analytics where (is_correct_json(json::json)) and (is_array(json::json->>'products')) How can I achieve that? 回答1: This is another good example why choosing the