A quick and dirty way to convert JSON to XML, using the popular Yahoo! Pipes platform.
Sometimes you want to convert a piece of JSON data to XML for readability, other times it might be part of some application logic that requires different data formats. In the past I have created a library (.NET DLL) that does some data formats conversions efficiently (so from XML to CSV, XML to JSON and so on) based on other 3rd party libraries, although its not really a quick way to get a quick output.
Yahoo! Pipes is essentially a small online Business Intelligence (BI) platform, it allows developer to quickly creates “pipes” or paths that the data will go through before being outputted, each step will involve a certain component that does some transformation or import of data. It is actually very similar to SSIS but with more of an online data manipulation focus.
To convert online available JSON files to XML using Yahoo! Pipes, we will be using a Yahoo Query Language (or YQL) to do the heavy lifting. YQL is pretty similar to SQL in terms of syntax.
The exact syntax for converting a JSON file to XML is:
and replace https://example.com/json with the JSON file URL.
To test your new script, you could use Yahoo!’s YQL Console
Here is the public URL to my YQL page converting Google Data API’s JSON to XML, this should give you a place to start.
Of course this is a very hacky way to convert JSON to XML, and if you integrate it within your application logic, you will introduce a dependency on Yahoo! Pipes. Yahoo! has been considering shutting the Pipes service for a while now. This method is recommended mostly for testing purposes.