As I work with a json file, my goal is to transform it into an object with a different format than the original file so that I can better utilize the data. This involves creating numerous variables with unknown names beforehand.
To dynamically create a new variable in my project, I use the following syntax:
object[variablename]
However, I am interested in more complex operations like:
library[musicLibrary.Key].name = musicLibrary.album;
and
library[musicLibrary.Key].songs.[musicLibrary.title].name = musicLibrary.song;
Is there a way for me to achieve this level of functionality?
Currently, my loop code for processing the json file looks as follows:
var library = {};
for(var i = 0; i < musicList.songs.length; i++) {
//read json and reorganize it into an object
}