I'm managing a JSON file like this example:
[
{
"Item": "Item1",
"ItemChild": [
{
"Category": "Category1",
"Inputs": [
{
"InputName": "1",
"InputTitle": "Title1",
},
]
},
{
"Category": "Category2",
"Inputs": [
{
"InputName": "2",
"InputTitle": "Title2",
},
]
}
]
}
]
I'm parsing this file, getting all the Category, InputName and InputTitle keys values and appending them in a file using this logic:
myParsedJSON.map(({ ItemChild }) => {
ItemChild.map(({ Category, Inputs }) => {
fs.appendFileSync(myfile, Category);
Inputs.map(({ InputName, InputTitle }) => {
fs.appendFileSync(myfile, InputName + ' - ' + InputTitle);
});
});
});
I want use an asynchronous version of this logic with async/await model and async operations. What's the best way to do that? Thanks