Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

ORDER BY name, jsonb_extract_path_text (values.jsonb,'id'), jsonb_extract_path_text (values.jsonb,'value')


    Final note
    • Note: if you want to include "ordinality" as part of your results – this is the order in which the extracted values appear in the source record – you would insert "WITH ordinality" before "AS values (jsonb)":
             CROSS JOIN LATERAL jsonb_array_elements (jsonb_extract_path (cf.jsonb, 'selectField', 'options', 'values')) WITH ordinality AS values (jsonb)

Then you would add a line in the Select stanza to show the ordinality: 
       values.ordinality AScustom_fields_ordinality


RESULT:

Image Modified


Extracting Arrays 

-- 2. Array is at the top-most hierarchical level in a table

...