I'm doing a one to many association with two tables: "usuarios" and "rol" here there is no problem, the issue is that I'm using the function "toJson" to convert the result of the consult to a String with json format, just like this:
[
{
"activo":1,
"alta":null,
"contrasenia":"AA123.aa",
"edicion":null,
"editor_alta":null,
"editor_edicion":null,
"email":"dadadada@ssfsfds",
"id_division":0,
"id_pools":1,
"id_roles":2,
"id_usuarios":1234567895,
"nombre":"Javier",
"primer_apellido":"a",
"segundo_apellido":"a",
"parents":{
"rols":[
{
"activo":1,
"alta":"2019-07-08",
"concepto":"Administrador Pool",
"descripcion":"Usuario que gestiona a los agentes",
"edicion":null,
"editor_alta":1111111111,
"editor_edicion":null,
"id_permisos":2,
"id_roles":2
}
]
}
}
]
But i only want to get some of the params in the json, for example I only want to have the "id_usuarios" and the "parents{rols[conecepto]}" params, so I indicate in the toJson method the name of this params but the result json is something like this:
[
{
"id_usuarios":1234567895,
"concepto":null,
"parents":{
"rols":[
{
"activo":1,
"alta":"2019-07-08",
"concepto":"Administrador Pool",
"descripcion":"Usuario que gestiona a los agentes",
"edicion":null,
"editor_alta":1111111111,
"editor_edicion":null,
"id_permisos":2,
"id_roles":2
}
]
}
}
]
As you can see it is not obtaining the "concepto" param, and it is including all the params of "parents".
So, is there any way to get just some parameters?, and how can i access to the values of the parents{rols} parameters?
I am using this code to create the json string
LazyList<Usuarios> usuarios = Usuarios.where("activo = 1").include(Rol.class);
String json = usuarios.toJson(true, "id_usuarios","concepto");
``