I have a grails application with mongodb plugin.

All my domain objects are:

```
class Person {
  ObjectId id
  String name
}

```

and

```
class Like {
  ObjectId id
  Person from
  Person to
  Date createdAt
}

```

My controller should give a full data according to some `Like` by id:

```
class MyController {
  def like() {
    def like = Like.findById(new ObjectId("someIdHere"));
    render(like as grails.converters.JSON)
  }
}

```

I wish to receive a full JSON-object of like:

```
{
  "class":"Like",
  "id":{
    "class":"org.bson.types.ObjectId",
    "inc":1483542456,
    "machine":805594765,
    "new":false,
    "time":1340363115000,
    "timeSecond":1340363115
  },
  "createdAt":"2012-06-22T11:05:15Z",
  "from":{
    "class":"Person",
    "id":{ ... },
    "name":"Some name here"
  },
  "to":{
    "class":"Person",
    "id":{ ... },
    "name":"Some name here"
  }
}

```

but I've receive first-level properties of object:

```
{
  "class":"Like",
  "id":{
    "class":"org.bson.types.ObjectId",
    "inc":1483542456,
    "machine":805594765,
    "new":false,
    "time":1340363115000,
    "timeSecond":1340363115
  },
  "createdAt":"2012-06-22T11:05:15Z",
  "from":{
    "class":"Person",
    "id":"4fd31d453004dc0f010aca51"
  },
  "to":{
    "class":"Person",
    "id":"4fd31d463004dc0f010aca89"
  }
}

```

My question is: is there any way to construct full (with referenced objects) JSON of mongo db (DBObject) data object? I've found out this [solution with JSONBuiled](https://stackoverflow.com/a/5543915) with escaped fields 'class', metaClass' and 'dbo'. But I think it can be done with Expando classes but I cann't find the right way...

Thanks any way,
Maksim