I hava a javacript object that look like this.
val =
{
default: "version1"
version1: "abc.com"
version2: "def.com"
...
versionn:"xyz.com"
}
I want to convert this to a nested json like this
"newval": {
"website": {
"url": "abc.com"
},
"versions": {
"version1": {
"website": {
"url": "abc.com"
}
},
"version2": {
"website": {
"url": "def.com"
}
}
}
}
My version uses a lot if if statements and unnecessary variables. Is there an elegant way to convert/create this JSON.
i.e the default version is the one that comes under newval.website and all the version data is the value fir newval.website.versions