-
-
Notifications
You must be signed in to change notification settings - Fork 404
Description
Software Environment
- MapServer version: 8.6.0
- PROJ version: 9.7
- GDAL version: 3.12
- Operating System: Linux (Docker container)
- Data source: Inline FEATURE data (reproducible without database)
mapserv -v
MapServer version 8.6.0 PROJ version 9.7 GDAL version 3.12 OUTPUT=PNG OUTPUT=JPEG OUTPUT=KML SUPPORTS=PROJ SUPPORTS=AGG SUPPORTS=FREETYPE SUPPORTS=CAIRO SUPPORTS=SVG_SYMBOLS SUPPORTS=RSVG SUPPORTS=ICONV SUPPORTS=FRIBIDI SUPPORTS=WMS_SERVER SUPPORTS=WMS_CLIENT SUPPORTS=WFS_SERVER SUPPORTS=WFS_CLIENT SUPPORTS=WCS_SERVER SUPPORTS=SOS_SERVER SUPPORTS=OGCAPI_SERVER SUPPORTS=FASTCGI SUPPORTS=GEOS SUPPORTS=PBF INPUT=JPEG INPUT=POSTGIS INPUT=OGR INPUT=GDAL INPUT=SHAPEFILE INPUT=FLATGEOBUF
Problem Description
When requesting features via OGC API Features endpoint, attributes containing JSON data (e.g., PostgreSQL JSONB fields) are returned as JSON-encoded strings instead of nested JSON objects/arrays. However, the same data requested via WMS GetFeatureInfo correctly returns nested JSON structures.
Comparison of Responses
WMS GetFeatureInfo (Correct - nested JSON):
{
"properties": {
"bgdi_id": 193138,
"auto_thickness_paper_link": ["a", {"b": 1}]
}
}OGC API Features (Incorrect - JSON-encoded string):
{
"properties": {
"bgdi_id": 193138,
"auto_thickness_paper_link": "[\"a\", {\"b\": 1}]"
}
}Expected Behavior
OGC API Features should return the same nested JSON structure as WMS GetFeatureInfo, treating complex data types (JSONB, JSON arrays, JSON objects) as native JSON values in the properties object, not as escaped strings.
How to Reproduce
Minimal Mapfile
Save the following as test.map:
LAYER
NAME "test_jsonb"
TYPE POLYGON
UNITS METERS
STATUS ON
PROCESSING "ITEMS=bgdi_id,auto_thickness_paper_link"
TEMPLATE "GetFeatureInfo"
METADATA
"wms_title" "test_jsonb"
"wms_enable_request" "*"
"wms_extent" "2300000 900000 3100000 1450000"
"ows_srs" "EPSG:2056"
"ows_include_items" "auto_thickness_paper_link"
"oga_enable_request" "OGCAPI"
"gml_include_items" "auto_thickness_paper_link"
"gml_featureid" "bgdi_id"
"wfs_encoding" "UTF-8"
END
FEATURE
ITEMS "193138;[\"a\", {\"b\": 1}]"
POINTS
2614500.0 1132200.0
2614500.0 1132250.0
2614450.0 1132250.0
2614450.0 1132200.0
2614500.0 1132200.0
END
END
PROJECTION
"init=epsg:2056"
END
EXTENT 2300000 900000 3100000 1450000
END
OUTPUTFORMAT
NAME "application/json"
DRIVER "OGR/GEOJSON"
MIMETYPE "application/json"
FORMATOPTION "STORAGE=memory"
FORMATOPTION "FORM=SIMPLE"
FORMATOPTION "LCO:COORDINATE_PRECISION=3"
FORMATOPTION "LCO:WRITE_BBOX=YES"
END
Test Requests
1. WMS GetFeatureInfo (returns nested JSON correctly):
curl -s 'http://localhost/wms?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetFeatureInfo&LAYERS=test_jsonb&QUERY_LAYERS=test_jsonb&CRS=EPSG:2056&BBOX=2614400,1132150,2614550,1132300&WIDTH=300&HEIGHT=300&I=150&J=150&INFO_FORMAT=application/json' | jq .2. OGC API Features (returns JSON-encoded string):
curl -s 'http://localhost/ogcapi/collections/test_jsonb/items/193138?f=json' | jq .Actual Results
OGC API Features serializes all attribute values as strings, losing the nested structure of JSON/JSONB data.
Impact
- Interoperability: Clients must conditionally parse strings based on which endpoint they use
Additional Context
This behaviour was discovered when migrating from WMS GetFeatureInfo to OGC API Features. The same PostgreSQL JSONB column behaves differently depending on the endpoint. A minimal test case using inline FEATURE data (shown above) proves this is not database-specific.