[mapserver-users] JSON template fail
    Mr. Puneet Kishor 
    punk.kish at gmail.com
       
    Sat Sep 10 21:09:37 PDT 2011
    
    
  
I was unable to achieve success with the suggestion for template at [http://mapserver.org/output/template_output.html]. So, I simplified my template like so --
// mapserver template
{
      "gid": "[gid]",
      "attrib1": "[attrib1]",
      "attrib2": "[attrib2]",
      "attrib3": "[attrib3]"
}
In my map file I have an output format declared like so
    OUTPUTFORMAT
      NAME "json"
      DRIVER "TEMPLATE"
      MIMETYPE "application/json"
      FORMATOPTION "FILE=/Users/punkish/Documents/www/gmap/lib/template.html"
    END
Note: MapServer croaks if I name the template "template.json"
The output from MapServer is 
1: {
2:      "gid": "2676",
3:      "attrib1": "foo",
4:      "attrib2": "bar",
5:      "attrib3": "baz"
6: }
gmap:-1 Resource interpreted as Script but transferred with MIME type text/html.
gmap:2 SyntaxError: Parse error
So, in spite of declaring the MIMETYPE as "application/json", the result is sent back with a "text/html" mime type (could that be because the template ends in .html?). And, what on earth is the "SyntaxError"? I don't see any. Does anyone?
    
    
More information about the MapServer-users
mailing list