1

i m using geoserver 2.1.3 i want to get the fields of layer from database http://[localhost]/geoserver/wfs?request=describeFeatureType&typename=topp:states this reurns me output in xml format how can i get it in json

2

The following request should work:

http://[hostname]/geoserver/wfs?request=GetFeature&typeName=topp:states&outputFormat=json
1

One solution to move from XML to JSON to use the yahoo YQL API. To familiarize you can use the YQL console (http://developer.yahoo.com/yql/console), and try a query like:

select * from xml where url = 'your xml describeFeatureType request'

and specify json as response format.

Note this YQL is particularly useful when you need to query xml data from Javascript and for which servers will reject xml request for security reasons. I personnally use this approach to query metadata xml files from OGC metadata catalogues.

0

The output formats listed in the documentation is for WFS GetFeature requests. Not for DescribeFeatureType.

If you look at

http://[localhost]/geoserver/ows?service=wfs&version=1.1.0&request=GetCapabilities

you can read that the DescribeFeatureType operation only supports the outputFormat

text/xml; subtype=gml/3.1.1

It's the same in newer versions of GeoServer as well. There are tools that can help you convert XML to JSON in almost every platform.

  • Hi! Any suggestions to how convert this wms.pcn.minambiente.it/ogc?map=/ms_ogc/wfs/… in a JSON? Unfortunately this WFS service does not support json directly ... I need to use it in a Leaflet map. Thank you very much in advance! Cesare – Cesare Jul 29 '14 at 18:51
  • @Cesare It's best to ask it as a question instead of in the comments. – R.K. Dec 3 '14 at 3:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.