You may be able to use keySource or keyDestination to solve your specific problem.
Example
In the following example, suppose we get data from an old-school relational database, where there is a one-to-many relationship between monster and Loot_Item . This relationship is expressed by the foreign Monster_Id foreign key in the Loot_Item table. Suppose also that our REST service does not have the slightest detail for us, since this seems to be quite close to the situation in your question.
keySource
Now, let the set set “keySource” to my foreign key (“Monster_Id”) and “key” to the attribute name, where I want the actual data to go (say, “Monster”). If you go into the debugger, you will see in the attribute object that there is actually a field called "Monster" and that it points to the data of the monster model. Hey cool!
includeInJSON
However, if you are to this puppy, guess what? He put all the monster data in Monster_Id, just like you didn’t want! Gah! We can fix this by setting "includeInJSON" to "Monster_Id". Now, when it is converted to JSON format, it puts the correct identifier back into the Monster_Id field when it serializes data in JSON format to send to the server.
Is the problem resolved? Er, well, actually, not necessarily ...
CAVEAT . It all sounds super-useful, but there is one pretty obvious problem I found with this scenario. If you use a template engine (for example, one in Underscore.js) that requires you to convert your model to JSON before passing it to a template, exclamations - you do not have access to relational data. Alas, the JSON that we want for our posts is not necessarily the same JSON that we want to feed into our templates.
source share