I'd like to use the PostgreSQL specific functions jsonb_set() or jsonb_insert(), which look a lot like their MySQL equivalents, and share some functionality with Oracle's JSON_TRANSFORM. But I'd like to work with a jsonpath specification, e.g.
-- Hypothetical syntax
SELECT jsonb_set('{"a": 1}'::jsonb, jsonpath_to_text_array('$.b'), '[1, 2]');
-- Equivalent to:
SELECT jsonb_set('{"a": 1}'::jsonb, '{b}', '[1, 2]');
To produce:
{"a": 1, "b": [2, 3]}
Assuming I cannot manually re-write the JSON path to the text[] representation, because I'm making query agnostic tooling, and as such, do not know the JSON path expressions in advance (they can even be dynamic expressions), is there a jsonpath_to_text_array() function that does this transformation for me, at least whenever it's "reasonably" possibe?