[mapserver-users] JSON template

Richard Greenwood richard.greenwood at gmail.com
Tue Mar 11 17:03:03 PDT 2014


The JSON template has *[feature trimlast=","]* for a single layer that may
return multiple records, but I don't see that functionality for the whole
JSON object. For example if I have two layers but only one returns results
I end up with a trailing comma and invalid JSON.

// MapServer template
{
  [resultset layer=layer1]
  {
    [feature trimlast=","]
    { ... }
    [/feature]
  },   // might need to trim this comma if layer below doesn't return result
  [/resultset]

  [resultset layer=layer2]
  {
    [feature trimlast=","]
    { ... }
    [/feature]
  }   // no comma here because we think it's last result object
  [/resultset]
}

I can work around it by putting a comma and empty object at the end:
   ,{}
which is the way I've done it when writing JSON with standard templates,
but that's sort of inconsistent with the [feature trimlast=","] option.

Am I missing anything? Should I file a feature enhancement request?

And trimlast="," does seem to need to require double, not single quotes.

Thanks,
Rich


-- 
Richard Greenwood
richard.greenwood at gmail.com
www.greenwoodmap.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20140311/926915cf/attachment.htm>


More information about the MapServer-users mailing list