[Pywps-dev] pywps - json output

Jachym Cepicky jachym.cepicky at gmail.com
Mon Oct 24 00:02:57 PDT 2016


Ok, let's do this for 4.2

po 24. 10. 2016 v 1:21 odesílatel Tom Kralidis <tomkralidis at gmail.com>
napsal:

> Another option is to extend PyWPS to support an 'outputformat'
> parameter like 'application/json' which would simply transform the XML
> response into JSON.  Or to be closer to the WPS spec allow one to
> define/send process input which allows takes over the entire response
> into JSON.
>
> Having said this, we do this for pycsw as very simple step just before
> the response is sent.  Examples:
>
> Example response:
>
> https://github.com/geopython/pycsw/blob/master/tests/expected/suites_default_post_GetRecordById-json.xml
> Code:
> https://github.com/geopython/pycsw/blob/master/pycsw/core/formats/fmt_json.py#L35
>
> Thoughts? Feel free to open a ticket if something like this would be
> useful.
>
> ..Tom
>
>
>
> On Sun, Oct 23, 2016 at 6:14 PM, Sylvain Beorchia
> <sylvain.beorchia at gmail.com> wrote:
> > Thank you for your answers.
> >
> > Jachym, i knew that WPS is XML a  based communication protocol, but i was
> > hoping for a full  JSON output.
> > I'm going to have a look at the rawdataoutput Jonas suggered.
> >
> > Thank you.
> >
> > Sylvain.
> >
> > 2016-10-23 22:26 GMT+02:00 Jachym Cepicky <jachym.cepicky at gmail.com>:
> >>
> >> Ah, yes, I almost forget about it
> >>
> >>
> >>
> >> ne 23. 10. 2016 v 22:10 odesílatel Jonas Eberle <jonas.eberle at gmx.de>
> >> napsal:
> >>>
> >>> Hi Sylvain,
> >>>
> >>> if you have only one output, you can use the rawdataoutput paramater,
> >>> just like this WPS request:
> >>>
> >>>
> >>>
> http://artemis.geogr.uni-jena.de/cgi-bin/testbox.cgi?service=WPS&version=1.0.0&request=Execute&identifier=fossgis_wps_proj&datainputs=[epsg_target=2927;epsg_source=4326;wkt=POINT(11%2051)]&rawdataoutput=output
> >>>
> >>> In your case it should be &rawdataoutput=out. Then you will get
> directly
> >>> the data from this output.
> >>>
> >>> Cheers,
> >>> Jonas
> >>>
> >>> ----- Am 23. Okt 2016 um 19:17 schrieb Sylvain Beorchia
> >>> <sylvain.beorchia at gmail.com>:
> >>>
> >>> Thank you for the fix Jachym.
> >>> But apparently it just changes the output, from :
> >>>
> >>> ...
> >>> <wps:ComplexData mimeType="application/geojson">
> >>> <![CDATA[
> >>>
> >>>
> WwogICJmb28iLCAKICB7CiAgICAiYmFyIjogWwogICAgICAiYmF6IiwgCiAgICAgIG51bGwsIAogICAgICAxLjAsIAogICAgICAyCiAgICBdCiAgfQpd
> >>> ]]>
> >>> </wps:ComplexData>
> >>>
> >>> to:
> >>>
> >>> <wps:ComplexData mimeType="application/geojson">
> >>> [ "foo", { "bar": [ "baz", null, 1.0, 2 ] } ]
> >>> </wps:ComplexData>
> >>>
> >>>
> >>> JSON, but still in XML result.
> >>> Am i doing something wrong in my code ?
> >>>
> >>>
> >>> Thanks .
> >>>
> >>> Sylvain.
> >>>
> >>>
> >>> 2016-10-23 8:01 GMT+02:00 Jachym Cepicky <jachym.cepicky at gmail.com>:
> >>>>
> >>>> Hi Sylvain,
> >>>> fixed in master https://github.com/geopython/pywps/pull/201
> >>>>
> >>>> Hope, it works
> >>>>
> >>>> J
> >>>>
> >>>>
> >>>>
> >>>> so 22. 10. 2016 v 23:42 odesílatel Sylvain Beorchia
> >>>> <sylvain.beorchia at gmail.com> napsal:
> >>>>>
> >>>>> Hi all,
> >>>>>
> >>>>> Trying to build my first WPS, i want to return JSON outputs. After
> many
> >>>>> tests, i always got some JSON encoded chars embeded in XML, or clear
> JSON
> >>>>> embeded in XML...always XML.
> >>>>> Here is the simple code i've tried :
> >>>>>
> >>>>>
> >>>>> import json
> >>>>> from pywps import Process, LiteralInput, LiteralOutput, OGCUNIT, UOM,
> >>>>> ComplexInput, ComplexOutput, Format, FORMATS
> >>>>>
> >>>>> class Test(Process):
> >>>>>     def __init__(self):
> >>>>>         inputs = [LiteralInput('name', 'Input name',
> >>>>> data_type='string')]
> >>>>>         outputs = [ComplexOutput('out', 'Referenced Output',
> >>>>> supported_formats=[Format('application/geojson')])]
> >>>>>
> >>>>>         super(Test, self).__init__(
> >>>>>             self._handler,
> >>>>>             identifier='cartogsm',
> >>>>>             title='Process Test',
> >>>>>             version='1.0.0.0',
> >>>>>             inputs=inputs,
> >>>>>             outputs=outputs,
> >>>>>             store_supported=True,
> >>>>>             status_supported=True
> >>>>>         )
> >>>>>
> >>>>>     def _handler(self, request, response):
> >>>>>         data = json.loads('["foo", {"bar":["baz", null, 1.0, 2]}]')
> >>>>>         out_bytes = json.dumps(data, indent=2)
> >>>>>         response.outputs['out'].output_format = 'application/json'
> >>>>>         response.outputs['out'].data = out_bytes
> >>>>>
> >>>>>         return response
> >>>>>
> >>>>>
> >>>>> Ouput :
> >>>>> ...
> >>>>> <wps:ProcessOutputs>
> >>>>> <wps:Output>
> >>>>> <ows:Identifier>out</ows:Identifier>
> >>>>> <ows:Title>Referenced Output</ows:Title>
> >>>>> <wps:Data>
> >>>>> <wps:ComplexData mimeType="application/geojson">
> >>>>> <![CDATA[
> >>>>>
> >>>>>
> WwogICJmb28iLCAKICB7CiAgICAiYmFyIjogWwogICAgICAiYmF6IiwgCiAgICAgIG51bGwsIAogICAgICAxLjAsIAogICAgICAyCiAgICBdCiAgfQpd
> >>>>> ]]>
> >>>>> </wps:ComplexData>
> >>>>> </wps:Data>
> >>>>> </wps:Output>
> >>>>> </wps:ProcessOutputs>
> >>>>> </wps:ExecuteResponse>
> >>>>>
> >>>>>
> >>>>> How can i return only JSON, with no XML at all ?
> >>>>>
> >>>>> Thank you.
> >>>>> _______________________________________________
> >>>>> pywps-dev mailing list
> >>>>> pywps-dev at lists.osgeo.org
> >>>>> http://lists.osgeo.org/mailman/listinfo/pywps-dev
> >>>
> >>>
> >>>
> >>> _______________________________________________
> >>> pywps-dev mailing list
> >>> pywps-dev at lists.osgeo.org
> >>> http://lists.osgeo.org/mailman/listinfo/pywps-dev
> >>>
> >>>
> >
> >
> > _______________________________________________
> > pywps-dev mailing list
> > pywps-dev at lists.osgeo.org
> > http://lists.osgeo.org/mailman/listinfo/pywps-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/pywps-dev/attachments/20161024/71fbc7b3/attachment-0001.html>


More information about the pywps-dev mailing list