Note that there are some explanatory texts on larger screens.

plurals
  1. PORender JSON-response from Controller in Grails 2.3.1
    text
    copied!<p>In my Grails-app I have two domains Person and County</p> <pre><code>class Person { String firstName String lastName County county LocalDate dateOfBirth static hasMany = [episodes: Episode] } class County { String name // other stuff... } </code></pre> <p>When trying to render my List of persons from my controller i only get County { class: County, id: 1 } not the name of County. I want the properties of objects related to my Person. </p> <pre><code>def index(Integer max) { params.max = Math.min(max ?: 10, 100) respond Person.list(params), model:[personInstanceCount: Person.count()] } </code></pre> <p>I don't want to default to the deep converter, then my belongsTo, and hasMany relations don't seem to work. </p> <pre><code>grails.converters.json.default.deep = true </code></pre> <p>I have tried and failed with customRenderers, Grails does not care about any changes i do there. </p> <pre><code> personRenderer(JsonRenderer, Person) { excludes = ['class'] } personsRenderer(JsonCollectionRenderer , Person){ excludes = ['class'] } countyRenderer(JsonRenderer, County) { excludes = ['class'] includes = ['name'] } countiesRenderer(JsonCollectionRenderer , County){ excludes = ['class'] includes = ['name'] } </code></pre> <p>I have tried with <code>CustomMarshallerRegistrar</code> same result as above, nothing happens at all, same result. Se 8.1.6.2 <a href="http://grails.org/doc/latest/guide/webServices.html#objectMarshallerInterface" rel="nofollow">http://grails.org/doc/latest/guide/webServices.html#objectMarshallerInterface</a></p> <p>So, how do i get my Person-objects to include the related County and not only the Class and ID properties?</p> <p>Im using Grails 2.3.1 with jdk 1.7 on Windows</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload