Skip to content

Return Postgres array as well-formed JSON list #47

Description

@sveniu

It would be great if Postgres arrays would be returned as bare, well-formed JSON lists, so that a result would look like this:

{ "rows": [
  { "col1": "foo", "arr1": [ "foo", "bar", "baz" ] }
]}

..including correct typing (no quotes around int[] or float[], etc).

The main benefit is ease of use by applications, not having to do something like a list comprehension to obtain the list of values.

The drawbacks include: Postgres only; XML has no concept of a list, so there would have to be a work-around using a parent-child element list.

This is a feature I've enjoyed immensely in the Python psycopg2 interface, and would love to carry on using it!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions