Bingen Galartza Iparragirre (
https://osgeo-org.atlassian.net/secure/ViewProfile.jspa?accountId=5b39e96b6e9a0b2e46a462cb
) *created* an issue
GeoServer (
https://osgeo-org.atlassian.net/browse/GEOS?atlOrigin=eyJpIjoiZmQ0NmVjOGUwM2NlNGQzY2E3ZTU2YmJmOWM3YWQ4YjQiLCJwIjoiaiJ9
) / Bug (
https://osgeo-org.atlassian.net/browse/GEOS-10218?atlOrigin=eyJpIjoiZmQ0NmVjOGUwM2NlNGQzY2E3ZTU2YmJmOWM3YWQ4YjQiLCJwIjoiaiJ9
) GEOS-10218 (
https://osgeo-org.atlassian.net/browse/GEOS-10218?atlOrigin=eyJpIjoiZmQ0NmVjOGUwM2NlNGQzY2E3ZTU2YmJmOWM3YWQ4YjQiLCJwIjoiaiJ9
) GetFeatureInfo documentation example template generates invalid JSON (
https://osgeo-org.atlassian.net/browse/GEOS-10218?atlOrigin=eyJpIjoiZmQ0NmVjOGUwM2NlNGQzY2E3ZTU2YmJmOWM3YWQ4YjQiLCJwIjoiaiJ9
)
Issue Type: Bug Affects Versions: 2.19.2 Assignee: Unassigned Components:
Documentation Created: 30/Aug/21 1:38 PM Priority: Lowest Reporter: Bingen
Galartza Iparragirre (
https://osgeo-org.atlassian.net/secure/ViewProfile.jspa?accountId=5b39e96b6e9a0b2e46a462cb
)
The sample template in the GetFeatureInfo Geojson templating documentation (
https://docs.geoserver.org/latest/en/user/tutorials/GetFeatureInfo/geojson.html
) might generate invalid JSON output.
The condition for adding the comma separators is not good enough, as it might
add a comma when the next attribute is a geometry. That will make some json
parsers to crash. A simple fix would be to use `filter` instead of `if`for
skipping the geometry attributes. The Freemarker documentation says the
following:
If you need to skip certain element in a list, it's generally a bad idea to use
if directive for that, because then <#sep>, item?has_next, item?counter,
item?index, item?item_parity, etc., will not be usable, as FreeMarker doesn't
know what items were and will be actually displayed. Instead, you should try to
remove the unwanted items from the sequence that you will list, and then list
it (since 2.3.29). Here are some typical examples with and without if.
So, I suggest to change the `properties` part of the example from this:
Unable to find source-code formatter for language: text. Available languages
are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go,
groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl,
php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
<#list feature.attributes as attribute2>
<# if !attribute2.isGeometry>
"${attribute2.name}" : "${attribute2.value}"
</# if >
<# if attribute2_has_next && !attribute2.isGeometry>
,
</# if >
</#list>
to this:
Unable to find source-code formatter for language: text. Available languages
are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go,
groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl,
php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
<#list feature.attributes?filter(a -> !a.isGeometry) as attribute>
"${attribute.name}" : "${attribute.value}"
<# if attribute_has_next>
,
</# if >
</#list>
(
https://osgeo-org.atlassian.net/browse/GEOS-10218#add-comment?atlOrigin=eyJpIjoiZmQ0NmVjOGUwM2NlNGQzY2E3ZTU2YmJmOWM3YWQ4YjQiLCJwIjoiaiJ9
) Add Comment (
https://osgeo-org.atlassian.net/browse/GEOS-10218#add-comment?atlOrigin=eyJpIjoiZmQ0NmVjOGUwM2NlNGQzY2E3ZTU2YmJmOWM3YWQ4YjQiLCJwIjoiaiJ9
)
Get Jira notifications on your phone! Download the Jira Cloud app for Android (
https://play.google.com/store/apps/details?id=com.atlassian.android.jira.core&referrer=utm_source%3DNotificationLink%26utm_medium%3DEmail
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailNotificationLink&mt=8
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100175-
sha1:61f0814 )_______________________________________________
Geoserver-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-devel