How to convert sql-text to jsonb-string?
问题 There does not seem to be an obvious way: select 'a123'::text::jsonb = ERROR: invalid input syntax for type json select '"a123"'::text::jsonb = BAD string because quoted check select '"a123"'::text::jsonb = ('{"x":"a123"}'::jsonb)->'x' to see that non-quoted is the correct . select '123'::text::jsonb = ('{"x":123}'::jsonb)->'x'; = NOT string I need '123' and 'a123' as pure JSONb strings . PS: it is not a duplicate of generic automatic-anything conversion. 回答1: To convert untyped string