Convert complex XML with element attributes to JSON
After first trying this. And getting to the point with attributes where the solution did not work
I stumbled upon this url. This solution worked out of the box.
Convert complex XML with element attributes to JSON
After first trying this. And getting to the point with attributes where the solution did not work
I stumbled upon this url. This solution worked out of the box.
I have been doing a mixed angularjs and grails project and ran into problems getting json to come back from the controller request with a withFormat block.
I expected that it would call the grails app controller index method and with the withFormat to pick out that the request came is as a json request so return json. This is not the case, it would send me back the html page instead.
The problem was that grails would see */* as the accept headers and return just the html.
def index() { def books = Book.findAll().collectEntries { book -> [book.title, book] }.values() withFormat { html books: books json { render books as JSON } } }
$http.get('/book/index').success(function(response) { }; }