I'm trying to improve the speed of a JSON parsing script, that creates an HTML file based on data inside of it.
The JSON file has a nested rows/columns/content modules structure, and I loop through them to transform every content module to HTML.
jsonFile.page.rows.map(row => {
row.columns.map(col =>{
col.modules.map(mod => {
switch(mod.type){
case "text":
// list of JSON handling functions;
break;
case "button":
// list of JSON handling functions;
break;
case "image":
// list of JSON handling functions;
// etc...
}
})
})
})
Since every content block is independent, I wanted to improve the speed of that loop and find a way to make the code asynchronous.
I'm quite new to asynchronous programming, and I've tried a few implementations of async/await without any luck (=> without any gain in terms of speed). This has lead me to a doubt: can async/await actually improve the performance of my code even if I don't have any call to external APIs in my code?
Can you suggest an approach to improve the speed of the above code? Thanks for your help!