This is a relatively simple one and I\'m pretty sure its just syntax.
Im trying to render multiple objects as json as a response in a controller. So something like this:
you could actually do it like so:
format.json {
render :json => {
:websites => @allWebsites,
:pages => @allPages,
:element_types => @AllElementTypes,
:element_data => @AllElementData
}
}
in case you use jquery you will need to do something like:
data = $.parseJSON( xhr.responseText );
data.websites #=> @allWebsites data from your controller
data.pages #=> @allPages data from your controller
and so on
EDIT:
answering your question, you don't necessarily have to parse the response, it's just what I usually do. There's a number of functions that do it for you right away, for example:
$.getJSON('/info', function(data) {
var websites = data.websites,
pages = data.pages,
...
});