Export XML data as JSON in Talend - json

In Talend, I have a job that received XML messages (of different structures) and call a web service with those messages. The tRestClient component automatically transforms the Xml into JSON when it calls my web service.
In case of an error, I want to save my message locally in JSON. Is there a component in Talend to automatically transform the XML into JSON (like the tRestClient do)?

Related

Convert and Transform JSON HTTP request to XML

I need to create a Logic Apps workflow with three steps:
When HTTP Request is received (JSON)
Convert Json from request to XML
Save XML file to FTP
What I have done so far:
Add action "When HTTP Request is received"
Add Liquid to Convert JSON to XML
(but i don't see option JSON to XML...Only Tranform JSON to JSON, JSON to
TEXT, XML to JSON, XML to TEXT)
Add action "FTP - Create file"
I also created Integration Account and try to add map for mapping JSON to XML, but I can't find any examples/templates to do this...
Is it possible at all ? Maybe there is another way to convert between these two formats ?
When you just want to convert a JSON payload to an XML file, without doing any transformation to the data, you can use the built-in xml() function of the Workflow Definition Language.
Detailed info in the docs: Workflow Definition Language reference #xml
I've made a small test Logic App to demo your usecase. It looks like this:
As you can see I use the xml function on the triggerbody #xml(triggerBody()) as an input for my FTP file content.
Remark: This will only work if your JSON message has a single rootnode. Otherwise the xml conversion will fail. You'll get this error:
The provided value cannot be converted to XML: 'JSON root object has multiple properties. The root object must have a single property in order to create a valid XML document. Consider specifying a DeserializeRootElementName.
You can work around that by concatenating a rootnode to your JSON payload. The function then would look like: #xml(json(concat('{\"rootnode\":',triggerBody(),'}')))
Good luck testing this out. Let me know if you need more help with this.

Convert JSON to XML Request using WSDL

I Have a SOAP web services which takes XML as input and send XML as response. Now I have a JSON object which is the same as XML request. How can I convert JSON Object to XML so that I can send the XML request to my SOAP web service. I have the WSDL file. In other terms, I wanted to provide a extra layer of REST on top of SOAP
A JSON object can never be "the same as" an XML document, because the data models are different. It may hold the same information, but the problem is that there is no definitive mapping from JSON to XML that is guaranteed to produce the XML representation that you are after.
There are a number of libraries available that do JSON to XML conversion: give them a try, but you will probably have to "tweak" the XML to get it into the required form. That can always be done using XSLT, of course.
If you use XSLT 3.0 then you can do the JSON to XML conversion and subsequent processing ("tweaking") in a single step.

How does a .json file work in a API call?

I've been doing research in order to write an API for a school project, and when referencing the API documentation of YouTube and Twitter, I see API URLs like this
https://api.twitter.com/1.1/account/settings.json
My understanding was that you execute a method on the backend which will return information to the caller, but I thought those files had to be of extension type .py or .java or whatever language you're using, and JSON was just the return type. I've been unable to find any information on how a .json file works in this example. Is there code in settings.json that is being executed?
JSON is just a format of your data, that you can then use, for example in JavaScript.
It is back-end language independent. By this I mean, that front-end of the application does not care who produced .json file.
Maybe it was Java application, maybe it was Python, or PHP application it does not matter. It can be also static file, with fixed content which just has json format.
After you receive such thing in front-end, you can do with it whatever you want. From your perspective it will be probably some kind of nested array.
In example you provided, I get:
{"errors":[{"code":215,"message":"Bad Authentication data."}]}
And it is fine, it's just data you get. It is JSON format - that is true. But you don't care that path has .json in the URL, it could have any extension, what is important is what's inside.
That is a beauty of JSON. You can prepare for yourself static file with mocked data in JSON format, and use it while developing front-end of the application. When you wish, you can have back-end application which will return real data for your app.
You can also see here, how to return json file from PHP:
Returning JSON from a PHP Script
Or here to see how to do it in Python (Django Framework):
Creating a JSON response using Django and Python

WSO2 API Gateway convert JSON to JSON

I need to configure JSON to JSON transformations with API Manager 2.0 very efficiently.
By default, WSO2 API Manager makes transformations JSON-> XML-> and after processing -> XML->JSON
I'd like to know how can I do so directly in JSON to reduce latencies.
Thank you for your help!!
By default, APIM uses PassThrough transport which does not build your message unless it needs to access your message body. So, your json won't be converted to XML in that case.
For example, if you have configured custom mediation and have a content-aware mediator like <log level="full"/>, APIM has to build (i.e. convert to XML) your message body so that it can log the entire message.
If you don't try to access the message body like that, json will be sent to backend as it is.

JasperReports Server using REST with JSON request return PDF report

I want to export reports in PDF from my app (Writed in MEAN) sending data to fill the report through the request.
It is possible to call JasperReports Server REST with a JSON file as a DataSource returning PDF report as output?
I found some examples using external datasource as JSON, but not sending JSON in request.