I have a big JSON file with “key:value” format like this:
{
"str1,str2,str3,str4,title": "VALUE OS THIS KEY",
"str1,str2,str3,str4,description": "VALUE OS THIS KEY",
"str1,str2,str3,str4,value": "VALUE OS THIS KEY",
...
"str1,str2,str3,str5,title": "VALUE OS THIS KEY",
"str1,str2,str3,str5,description": "VALUE OS THIS KEY",
...
"str1,str_other,str3,str4,title": "VALUE OS THIS KEY",
...
}
And I want to transform this keys into an object to make a new JSON and work with it like this:
{
str1:{
str2:{
str3:{
str4:{
title: "VALUE OS THIS KEY",
description: "VALUE OS THIS KEY",
value: "VALUE OS THIS KEY"
},
str5:{
title: "VALUE OS THIS KEY",
description: "VALUE OS THIS KEY"
}
}
},
str_other: {
str3:{
str4:{
title: "VALUE OS THIS KEY"
}
}
}
}
}
I try it with javascript forEach but I don’t know how to create this multidimensional array.
Can anyone show me how to do that?
Thank you very much in advance