The problem is that there is no single standard for converting XML to JSON.


The following site shows that there are at least 7 conversion methods to
convert XML to JSON: http://wiki.open311.org/JSON_and_XML_Conversion/

Is it possible that the API you are calling would utilize a `Accept:
application/json` header that would return the result in JSON instead of
XML?

Otherwise, writing your own filter might be required.

On Tue, May 8, 2018 at 2:44 PM, Madushan Chathuranga <
[email protected]> wrote:

> Hi,
>
> Thank you very much for the response. First let me explain what I'm trying
> to do here and then what I have done so far.
> I'm trying to call and rest api which I'm using URI module to do that.
> Success response of this api returns a xml response not json. But my end
> user needs the output from my ansible playbook to be json so others can
> consume it for other processes. This xml response comes in the content of
> the response. E.g. return_content : yes . So this content is a string which
> is in xml format. I need to sanitize it to remove characters like \n (new
> line). That's been done using regex_replace. So then we get the plain xml.
> Now this xml output needs to be shown in json manner.
> What i have been thinking and trying to do so far is create a python scrip
> which does the job. Then call the method in python script as a filter e.g.
> "{{ xml_response | xml_to_json}}". But stucked here on implementing this.
> Are there any easier work around for this?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/ansible-project/4d0c1c1f-ca37-49b4-9402-b73ff9f1db28%40googlegroups.
> com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Matt Martz
@sivel
sivel.net

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAD8N0v9Mqa-MhkTWiCLwDieDf8YveKyco_vAryPfY6YTt7P3rw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to