Categories
HowTo's VSCP

#VSCP HOWTO: Get MDF content in JSON or JSONP

To get a XML file in JavaScript can be difficult due to the same origin policyCORS is on solution but using  JSONP is a much simpler solution also because JavaScript kind of like the JSON format.

The problem here for VSCP is that the MDF (Module Description File) is in XML format. We therefore need a conversion.

This PHP scripts will handle this and out put a local xml file in JSON/JSONP format

Screenshot from 2016-02-02 11:50:50

You can test the output for the Paris module

here.

In this case the local MDF file is paris_010.xml and we request JSONP output using the function “callback”.

If we skip the

&jsonp=callback

we get pure JSON output instead.

The script can be downloaded here.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.