I am working with an API that generates responses in the form of a dynamic array of strings, like the example below:
var arr = ["Request.name","Request.name.first","Request.name.first.last"]; //response 3
My goal is to dynamically convert this array into an array of JSON objects structured like this:
var arrayOfObjects = [
{
"Request": {
"name":val
}
} //converted from arr[0]
,{
"Request": {
"name":{
"first":val
}
}
} //converted from arr[1]
,{
"Request": {
"name":{
"first":{
"last":val
}
}
}
} //converted from arr[2]
];
and so on...
Do you think this conversion process is possible?