My desired output is at the bottom of this post, I want to remove the array and put a list of objects inside an object.
I'm sharing my map function because i'm hopeful that there's a method inside there that can get my desired input and i'm just not doing it correctly.
If what i'm doing doesn't make sense i would love a better method of manipulating this data.
Starting Data(./updatepayloadTEMP.json)
{
"outputparameters": [
{
"name": "0000x0000",
"filepath": "D:\\Code\\ImageTiling\\6\\0000x0000.png"
},
{
"name": "0000x0001",
"filepath": "D:\\Code\\ImageTiling\\6\\0000x0001.png"
},
{
"name": "0000x0002",
"filepath": "D:\\Code\\ImageTiling\\6\\0000x0002.png"
}
]
}
Variables
let UpdatedTaskOutput = fs.readFileSync('./updatepayloadTEMP.json');
let Updatedtaskoutputjson = JSON.parse(UpdatedTaskOutput);
var dynamictaskdetails = Updatedtaskoutputjson.outputparameters;
MAP func
var taskparamscompiled = dynamictaskdetails.map(function (elem) {
taskname = tasknamefromworkflowdef + elem.name;
taskparms = taskparamsobj;
return {
[taskname]: taskparms,
};
});
What i'm currently getting for taskparamscompiled
[
{
process0000x0000: {
tr: 16,
tc: 16,
ofr: 16,
ofc: 16,
outfile: '"D:\\Code\\Process\\1"',
},
},
{
process0000x0001: {
tr: 16,
tc: 16,
ofr: 16,
ofc: 16,
outfile: '"D:\\Code\\Process\\1"',
},
},
{
process0000x0002: {
tr: 16,
tc: 16,
ofr: 16,
ofc: 16,
outfile: '"D:\\Code\\Process\\1"',
},
},
];
What I want
{
"process0000x0000": {
"tr": 16,
"tc": 16,
"ofr": 16,
"ofc": 16,
"outfile": '"D:\\Code\\Process\\1"'
},
"process0000x0001": {
"tr": 16,
"tc": 16,
"ofr": 16,
"ofc": 16,
"outfile": '"D:\\Code\\Process\\1"'
},
"process0000x0002": {
"tr": 16,
"tc": 16,
"ofr": 16,
"ofc": 16,
"outfile": '"D:\\Code\\Process\\1"'
},
}
I missed something, UPDATE:
I now need to get the filepath ( "filepath": "D:\\Code\\ImageTiling\\6\\0000x0000.png") into the process object like this
process0000x0000: {
filepath: "D:\\Code\\ImageTiling\\6\\0000x0000.png"
tr: 16,
tc: 16,
ofr: 16,
ofc: 16,
outfile: '"D:\\Code\\Process\\1"',
}