Keyword

[SOLVED] How does JSON output work?

  • RichardManDX
  • RichardManDX's Avatar Topic Author
  • Offline
  • New Member
More
11 years 5 months ago - 11 years 5 months ago #112395 by RichardManDX
[SOLVED] How does JSON output work? was created by RichardManDX
Hello,

I was wondering how to use the JSON output of K2. According to the documentation, it's suposed to work like this:

We are introducing JSON & JSONP content output. This is phase 1 towards a true REST capable K2 release coming in version 3. We want you to be able to turn your Joomla! & K2 website into a source of content ready to be consumed or updated by third-party applications, e.g. a mobile application that reads and posts content to your K2 powered Joomla! website. Or simple stuff like AJAX calls are now a piece of cake for developers. To quickly set you up, just append 'format=json&limit=X&page=Y' to any K2 generated URL, replacing X with the number of items you want to fetch (with a forced limit of 100) and Y as the page number (if you wish to break your results in pages). At its simplest form, just append 'format=json' to get the default K2 output in JSON. The additional GET parameters mentioned above only work in categories, user pages, tags etc. If you append 'format=json' to an item URL you will get all the item's contents in JSON format. Additionally, you can pass a callback function to the above URLs in case you want to wrap the output in a function. The format is 'format=json&callback=Z', replacing Z with your callback function name.


However, it doesn't work. Should i turn off the Joomla 2.5 URL rewriting in order to use it?
I would like a little more documentation on this particular issue.

Can someone please provide me a small example of how the URL should look like to append 'format=json' in order to get the info in that way?

Thanks in advance.

UPDATE:

Ok, i forgot to search the forum first. My bad.
I found an example like this:
index.php?option=com_k2&view=itemlist&layout=category&format=json

And it outputs beautifully a JSON file.

This will come in handy to create an app based on the content of my website :)

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum