title: How to pass reference to an object as JSON in a POST in grails
body: <p>I have 2 classes <code>Person</code> and and <code>Designation</code>. I am using <code>@Resource</code> annotation to make them restful</p>
  
  <pre><code>            import grails.rest.Resource
              @Resource(formats=['json', 'xml'])
  
                 class Person {
                                 String name 
                                 static belongsTo = [designation:Designation] 
  
                              static constraints = {  }
                              }
  </code></pre>
  
  <p>and <code>Designation</code> class is   </p>
  
  <pre><code>                import grails.rest.Resource
                  @Resource(formats=['json', 'xml'])
  
                     class Designation {
                                     Long designationId
                                     String name 
  
  
                                  static constraints = {  }
                                  }     
  </code></pre>
  
  <p>Since I'm using grails default resource url mapping like </p>
  
  <pre><code>"/app/person"(resources: "person",  includes: ['index', 'show', 'save', 'update', 'delete', 'create', 'patch'])
  </code></pre>
  
  <p>I want to prform insert to Person object using POST request to <code>/app/person</code> with json data.
  Since <code>designation</code> is belongs to another object , I need to pass only a reference to an existing  Designation object id
  how do i pass this via json? what is the json format to do the same?
  or can I access the params in beforeInsert() method of Person class , so that i can manually get designatioId , then find Designation object with that id , then assign it new Person object?</p>