...
jsonb_extract_path_text (values.jsonb,'id') as value_id, ----- note that in this case, the "id" we're getting is a text element, not a UUID
jsonb_extract_path_text (values.jsonb,'value') as value_name
------ because "values" is a jsonb object (produced by the cross join below), we need to use json extract statements in "Select" to get the value _ id and the value _ name from "values"
FROM folio_users.custom_fields AS cf
CROSS JOIN LATERAL jsonb_array_elements (jsonb_extract_path (cf.jsonb, 'selectField', 'options', 'values')) AS values (jsonb)
----- "jsonb_array_elements" works on the 'values' element in the parentheses; it specifies that we use this call because "values" is an array
----- "jsonb_extract_path" works on the "selectField" and "options" objects – the order of objects listed must be in the same hierarchical order as they appear in the table
----- the entire cross join statement produces a jsonb object named "values" (note: what you name this object is totally arbitrary - you could call it "stuff")
LEFT JOIN folio_users.custom_fields__t AS cft
...
Then you would add a line in the Select stanza to show the ordinality:
values.ordinality AS custom_fields_ordinality
...