After reaching out to a downstream source, the response received looks something like this:
// for simplicity's sake, let's refer to this variable as resp
{
"data":{
"abc": {
"value":"Hi there",
"timestamp":"xxxxxxxxxx"
}
}
}
My next task is to access resp.data.abc.value
, but the challenge lies in doing it dynamically (meaning that the data.abc.value
part is sourced from a database)
The logic flow of my program follows these steps:
/*
(a) Initiate a REST call
(b) Receive and store the response in a variable named "resp"
(c) Fetch the dot-separated path from the database
(d) The database outcome will be "data.abc.value" with data type being string
(e) Devise a method to dissect the DB result and apply it to the "resp" variable value
*/
I attempted utilizing .split()
and implementing a loop, yet it's becoming convoluted and intricate to grasp.