How to feed a dynamic dropdown with a rest service which send application/json

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

How to feed a dynamic dropdown with a rest service which send application/json

vicaed
Hi everyone, I don´t get feed the dynamic dropdown when I receive data from a
web service in JSON format. I can use the same service if i get xml setting
the dropdown as follow:

resource url: http://opendata.gijon.es/descargar.php?id=113&tipo=XML
xpath expression for the node:
/empresa_grupo_niveles/empresa_grupo_nivel/num_empleados
xpath expression for label and value: .

and to consum JSON I tried:

resource url: http://opendata.gijon.es/descargar.php?id=113&tipo=JSON
xpath expression for the node: /empresa_grupo_niveles or
instance()/empresa_grupo_niveles neither works
xpath expression for label and value: instance()/empresa_grupo_nivel/_[2]

Please notice that I test with the http service that web service is working
with both xml and JSON format, I think the problem is that I don't write the
right xpath expression for JSON.


--
Sent from: http://discuss.orbeon.com/

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Reply | Threaded
Open this post in threaded view
|

Re: How to feed a dynamic dropdown with a rest service which send application/json

vicaed
Ok, I got it so I will respond to myself just in case someone could have the
same doubte. The json structure is as I show below:
<http://discuss.orbeon.com/file/t375607/json_structure.png>

So the right Xpath expresion is:

- For the node:
/instance()/empresa_grupo_niveles/empresa_grupo_nivel/_[.]/num_empleados . I
think one of my previous mistakes was ommit the initial '/' . And apparently
if you put '.' in the array element, you get all elements of the array, then
if every element is a group of elements you have to specify what of them you
want to show, in my case '/num_empleados

- For the value: I just wrote '.'

--
Sent from: http://discuss.orbeon.com/

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Reply | Threaded
Open this post in threaded view
|

Re: How to feed a dynamic dropdown with a rest service which send application/json

Alessandro  Vernet
Administrator
Hi Vicente,

Sorry for the late response. I'm glad your persistence paid off, and you
should also be able to use the following, which is a but a simpler than what
you had:

Choices XPath: /json/empresa_grupo_niveles/empresa_grupo_nivel/_
Label XPath: num_empleados
Value XPath: num_empleados

Orbeon Forms follows the rules defined in the XForms 2.0 spec to convert
JSON to XML (see link below), but granted, we can't expect everyone to be
familiar with those rules ;), so I think it might be useful to offer a
preview that XML somewhere. We could maybe do this in the HTTP Service
Editor, since we already have a Test Results tabs there. We'll need to think
a little bit more about this one.

https://www.w3.org/community/xformsusers/wiki/XForms_2.0#External_JSON_values

Alex

-----
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
--
Sent from: http://discuss.orbeon.com/

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: How to feed a dynamic dropdown with a rest service which send application/json

Alessandro  Vernet
Administrator
Hi Vicente,

And for reference, we've added this RFE:
https://github.com/orbeon/orbeon-forms/issues/3474

Alex

-----
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
--
Sent from: http://discuss.orbeon.com/

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: How to feed a dynamic dropdown with a rest service which send application/json

vicaed
In reply to this post by Alessandro Vernet
Hi Alex, thanks you for the additional information.

--
Sent from: http://discuss.orbeon.com/

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].