Prestashop Web service to return JSON

Saba Sarwat picture Saba Sarwat · May 30, 2013 · Viewed 18k times · Source

After extensive search over internet i am sure that Prestashop does not return data in JSON format, it only returns in XML format (which leads to cross domain accessing issue unfortunately).

Now, I am trying to convert XML(returned by Prestashop) to JSON. I want to write php code which could take XML from web service and sent back JSON. For this purpose i tried many tutorial but in vain. The converted JSON does not have value in it, so is useless. The methods i tried are listed below.

http://www.sitepoint.com/php-xml-to-json-proxy/
PHP convert XML to JSON

XML to convert:

<name>
<language id="1" xlink:href="http://localhost/prestashop/api/languages/1">
<![CDATA[ iPod Nano ]]>
</language>
</name>

Returned JSON:

"name":{"language":{"@attributes":{"id":"1"}}}

Answer

Mikuso picture Mikuso · Nov 3, 2014

I don't know about historical support for this, but...

In the latest version of Prestashop (currently v1.6.0.9), you can get a JSON response from any WebService API request by appending output_format=JSON to your request query string.

E.g. http://example.prestashop.com/api/products?output_format=JSON