How can I serve JSON and XML data, like Vanilla does with Categories?
I noticed that, with many pages in Vanilla, it's possible to simply add ".xml" or ".json" and have the page content returned in these formats (e.g. http://localhost/vanilla/categories.json). I'm trying to achieve the same with a plugin, but I'm having difficulties. As I expected, to request JSON or XML data it's not just a matter of adding a suffix. In my case, I create a Controller_MyPlugin() method, but I can't simply call http://localhost/vanilla/myplugin.json and get back Json data. So, first question is how do I "receive" these requests?
Once the JSON/XML request arrives, I guess I'll have to use a switch statement to choose what to render, but I'm not sure of this either, as "categories" controller doesn't do it.
Thanks in advance for the answers.