[postgis-tickets] [PostGIS] #4798: ST_AsGeoJSON should warn about duplicate keys
PostGIS
trac at osgeo.org
Fri Nov 20 18:11:50 PST 2020
#4798: ST_AsGeoJSON should warn about duplicate keys
----------------------------------+---------------------------
Reporter: tobwen | Owner: pramsey
Type: enhancement | Status: new
Priority: medium | Milestone: PostGIS 3.1.0
Component: postgis | Version: master
Keywords: geojson, json, jsonb |
----------------------------------+---------------------------
== description
Although all JSON specifications (RFC 8259, RFC 7159, RFC 4627, and
ECMA-404) allow multiple columns with the same name, PostgreSQL's JSONB
does not. JSONB just takes the last occurance.
Most validators warn about duplicate columns, maybe PostGIS should warn
about this, too? It might result in expected behaviour when storing as
JSONB.
== example
{{{
SELECT
ST_AsGeoJSON(data.*)
FROM
(SELECT
1 AS column,
2 AS column,
ST_Transform(geom, 3035) geom
FROM
ST_SetSRID(ST_MakePoint(7, 51), 4326) geom
) data;
}}}
== result JSON
{{{
{
"type":"Feature",
"geometry":{
"type":"Point",
"crs":{
"type":"name",
"properties":{
"name":"EPSG:3035"
}
},
"coordinates":[
4110471.051819585,
3103060.820290524
]
},
"properties":{
"column":1,
"column":2
}
}
}}}
== result JSONB
{{{
{
"type":"Feature",
"geometry":{
"crs":{
"type":"name",
"properties":{
"name":"EPSG:3035"
}
},
"type":"Point",
"coordinates":[
4110471.051819585,
3103060.820290524
]
},
"properties":{
"column":2
}
}
}}}
--
Ticket URL: <https://trac.osgeo.org/postgis/ticket/4798>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.
More information about the postgis-tickets
mailing list