Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support unnesting of JSONB fields #165

Merged
merged 1 commit into from
Nov 4, 2024

Conversation

JakobMiksch
Copy link
Contributor

Minor fix to unnest values from JSONB fields in GeoJSON output.

Output before:

{
    "type": "FeatureCollection",
    "features": [
        {
            "type": "Feature",
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            8.9000685,
                            53.1099145
                        ],
                        [
                            8.9001737,
                            53.109878
                        ],
                        [
                            8.9002618,
                            53.1099697
                        ],
                        [
                            8.9001565,
                            53.1100061
                        ],
                        [
                            8.9000685,
                            53.1099145
                        ]
                    ]
                ]
            },
            "properties": {
                "osm_id": 249727578,
                "osm_type": "W",
                "tags": "{\"club\": \"sport\", \"name\": \"BTC - Borgfelder Tennisclub\", \"building\": \"yes\"}" <-- HERE
            }
        }
    ],
    "numberReturned": 1,
    "timeStamp": "2024-03-31T19:25:21+02:00",
    "links": [
        {
            "href": "http://localhost:9000/collections/postgisftw.osm_feature_info/items",
            "rel": "self",
            "type": "application/json",
            "title": "This document as JSON"
        },
        {
            "href": "http://localhost:9000/collections/postgisftw.osm_feature_info/items.html",
            "rel": "alternate",
            "type": "text/html",
            "title": "This document as HTML"
        }
    ]
}

Output after:

{
    "type": "FeatureCollection",
    "features": [
        {
            "type": "Feature",
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            8.9000685,
                            53.1099145
                        ],
                        [
                            8.9001737,
                            53.109878
                        ],
                        [
                            8.9002618,
                            53.1099697
                        ],
                        [
                            8.9001565,
                            53.1100061
                        ],
                        [
                            8.9000685,
                            53.1099145
                        ]
                    ]
                ]
            },
            "properties": {
                "osm_id": 249727578,
                "osm_type": "W",
                "tags": {    <-- HERE
                    "building": "yes",
                    "club": "sport",
                    "name": "BTC - Borgfelder Tennisclub"
                }
            }
        }
    ],
    "numberReturned": 1,
    "timeStamp": "2024-03-31T19:22:09+02:00",
    "links": [
        {
            "href": "http://localhost:9000/collections/postgisftw.osm_feature_info/items",
            "rel": "self",
            "type": "application/json",
            "title": "This document as JSON"
        },
        {
            "href": "http://localhost:9000/collections/postgisftw.osm_feature_info/items.html",
            "rel": "alternate",
            "type": "text/html",
            "title": "This document as HTML"
        }
    ]
}

@jmealo
Copy link

jmealo commented Jul 9, 2024

@JakobMiksch Kudos on the PR! I think I'll need this before I can move forward evaluating pg_featureserv any chance we can get this merged?

@JakobMiksch
Copy link
Contributor Author

I would be happy to merge it as well. We should ask @dr-jts for his opinion

@dr-jts
Copy link
Collaborator

dr-jts commented Nov 4, 2024

Looks good to me. Merging it now.

@dr-jts dr-jts merged commit 35cb1f1 into CrunchyData:master Nov 4, 2024
3 checks passed
@JakobMiksch JakobMiksch deleted the jsonb-unnest branch November 4, 2024 23:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants