Grails: Rendering JSON using executeQuery -


i testing out controller , want retrieve json. however, i'm noticing controller returns data not return json key/value pairs. literally returns data. notice however, if use incident.getall(), returns json properly. example, return [incidentid: "value"] opposed using executrequery returns data.

my code:

def incident = incident.executequery("select a.incidentid incident a") render incident json 

the result executequery list of properties specified, not actual domain objects. example:

testdomain.executequery("select t.id testdomain") json ===> [1, 2, 3] 

if want domain objects, can use findall instead. try this:

testdomain.findall("from testdomain") json ===>[{"class":"testdomain","id":1,"name":"one"},   {"class":"testdomain","id":2,"name":"two"},   {"class":"testdomain","id":3,"name":"three"}] 

Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -