I’m using Java SDK, and I’m executing a fetch query, everyting runs perfectly, but is there a way (a little easier) to parse/map the fetch result to a POJO?
The thing is, I’m using this schema and data: Parent without children does not get returned - #4 by nico_bondarenco
And when I get the fetch result, it’s a JSON, but the attributes values are not directly accessible.
I understand that this is the way TypeDB works, but I’m searching for a easier way to get the “entity” representation of my model, instead of getting each attribute and iterate the array checking if there is a “value” object to get the actual value.
Using the example of my other topic, the result o the fetch is:
{
"user": {
"first_name": [ { "value": "Tony", "type": { "label": "first_name", "root": "attribute", "value_type": "string" } } ],
"id": [ { "value": "90113601-0e7b-4d07-8e71-2f8f44e6fc9f", "type": { "label": "id", "root": "attribute", "value_type": "string" } } ],
"last_name": [ { "value": "Stark", "type": { "label": "last_name", "root": "attribute", "value_type": "string" } } ],
"main_email": [ { "value": "iron.man@email.com", "type": { "label": "main_email", "root": "attribute", "value_type": "string" } } ],
"profile_photo": [ ],
"type": { "label": "user", "root": "entity" }
},
"user_roles": [
{
"role": {
"role_authority": [ { "value": "ROLE_USER_CREATE", "type": { "label": "role_authority", "root": "attribute", "value_type": "string" } } ],
"type": { "label": "role", "root": "entity" }
}
},
{
"role": {
"role_authority": [ { "value": "ROLE_USER_READ", "type": { "label": "role_authority", "root": "attribute", "value_type": "string" } } ],
"type": { "label": "role", "root": "entity" }
}
},
{
"role": {
"role_authority": [ { "value": "ROLE_USER_UPDATE", "type": { "label": "role_authority", "root": "attribute", "value_type": "string" } } ],
"type": { "label": "role", "root": "entity" }
}
}
]
}
Is there a way to get the result as something like this:
Or some Java class that do the parser more easily?
{
"user": {
"id": "90113601-0e7b-4d07-8e71-2f8f44e6fc9f",
"first_name": "Tony",
"last_name": "Stark",
"main_email": "iron.man@email.com",
"profile_photo": null
},
"user_roles": [
"ROLE_USER_CREATE",
"ROLE_USER_READ",
"ROLE_USER_UPDATE"
]
}