I am new to Java programming and I am working on a Spring Boot application with a REST service which will call another service and return a JSON response. I am using OkHttpClient for handling this call.
However from the JSON response, I only require few attributes as final output in List format.
How can I extract only the required attributes from my okHttpCliwnt response ?
My response from the third party service looks like below :
{
"employeeDetail": [{
"employee": {
"name": "abc",
"age": "30",
"details": {
"role": "developer",
"phone": "123"
}
}
},
{
"employee": {
"name": "abc",
"age": "30",
"details": {
"role": "sr.developer",
"phone": "1234"
}
}
}
]
}
From this response, my final response needs to only be like below:
{
"employeeDetail": [{
"name": "abc",
"age": "30",
"role": "developer"
},
{
"name": "abc",
"age": "30",
"role": "sr.developer"
}
]
}
Please assist me.