Skip to content

Instantly share code, notes, and snippets.

@jjl
Created January 31, 2014 19:07
Show Gist options
  • Select an option

  • Save jjl/8740872 to your computer and use it in GitHub Desktop.

Select an option

Save jjl/8740872 to your computer and use it in GitHub Desktop.
The missing useful postgresql json function
CREATE OR REPLACE FUNCTION json_array_elements_text(arr json) RETURNS SETOF text AS $$
BEGIN
RETURN QUERY SELECT arr->>i
FROM generate_series(0,json_array_length(arr)-1) i;
END
$$ LANGUAGE plpgsql;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment