Preventing 'invalid input syntax for type json' in Postgres
问题 I have a text column that contains JSON and also plan text. I want to convert it to JSON, and then select a particular property. For example: user_data _________ {"user": {"name": "jim"}} {"user": {"name": "sally"}} some random data string I've tried: select user_data::json#>'{user,name}' from users I get: ERROR: invalid input syntax for type json DETAIL: Token "some" is invalid. CONTEXT: JSON user_data, line 1: some... Is it possible to prevent this? 回答1: If you want to skip the rows with