Grunt task to assemble JSON files from filenames in JSON

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


Grunt task to assemble JSON files from filenames in JSON



I have a JSON file that looks like:


{
"someRandomStuff": "myRandomStuff",
"includeNodesFromFiles": {
"item1": "item1.json",
"item2": "item2.json",
"item3": "item3.json"
}
}



And now I want to replace item1, item2, and item3 with JSON content from each respective file, so the destination file would look like:


{
"someRandomStuff": "myRandomStuff",
"includeNodesFromFiles": {
"item1": {"whatever": "...whatever was in item1.json"},
"item2": {"whatever": "...whatever was in item2.json"},
"item3": {"whatever": "...whatever was in item3.json"},
}
}



Or similarly for an array:


{
"someRandomStuff": "myRandomStuff",
"includeNodesFromFiles": [
"item1.json",
"item2.json",
"item3.json"
]
}



To:


{
"someRandomStuff": "myRandomStuff",
"includeNodesFromFiles": [
{"whatever": "...whatever was in item1.json"},
{"whatever": "...whatever was in item2.json"},
{"whatever": "...whatever was in item3.json"}
]
}



How could I do that with Grunt? I'm not finding a Grunt task that will do that out-of-the-box so far.









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Arduino Mega cannot recieve any sketches, stk500_recv() programmer is not responding

Visual Studio Code: How to configure includePath for better IntelliSense results

C++ virtual function: Base class function is called instead of derived