I have a similar problem to this: Grails get child domain objects
I'll just paste domain class code from the link for the post to be mor readable:
class Parent{
String name
static hasMany = [childs:Child]
static constraints = {
}
}
class Child{
String name
static belongsTo = [parent:Parent]
static constraints={}
}
I have created custom marshaller for Parrent object that produces something like below. How do I receive and save a complex JSON object like that one ? (I want to receive identical objects like the one that marshaller generated for me)
[{"class":"project.Parent","id":1,"name":"name1",
"childs":[{"class":"Child","id":1,"name":"childname1"},
{"class":"Review","id":2,"name":"childname2"}
]
}]
besides JSON if I had, say, all the parameters like "name" and such, the default saving code in my app is:
def parrent = new Parrent("parr_name")
parrent.save()
def child = new Child("child_name", parrent)
child.save()
Do I have to send JSON object separately? or could I just receive complex json and drag out map of args? Does the marshaller implemented for display JSON in such manner is capable of receiving one in similar format? I am using grails v2.3.3