a) Here is an example of an array containing objects with various properties:
[
{
"Account": "1111-000",
"Desc": "Accrued - Payroll & Payroll Tax",
"Amount": "-8,459.88",
"Partner": "RAP",
"FY": "2018",
"PD": "10",
"VNO": "abc"
},
{
"Account": "2222-000",
"Desc": "Accrued - Management Fee",
"Amount": "-9,228.33",
"Partner": "RAP",
"FY": "2018",
"PD": "10",
"VNO": "dfe"
},
{
"Account": "3333-000",
"Desc": "Current Year Earnings",
"Amount": "0",
"Partner": "RAP",
"FY": "2018",
"PD": "10",
"VNO": "bcd"
},
]
b) To create a specific output based on the values from each object, I plan to iterate through the array and use a constructor function as follows:
gridinsert: [{
value: "1111-000",
command: "setGridValue",
columnID: "17"
}, {
value: "Accrued-Payroll & payroll tax",
command: "setGridValue",
columnID: "18"
}, {
value: "-8,459.88",
command: "setGridValue",
columnID: "19"
}, {
value: "RAP",
command: "setGridValue",
columnID: "20"
}, {
value: "2018",
command: "setGridValue",
columnID: "12"
}, {
value: "10",
command: "setGridValue",
columnID: "21"
}, {
value: "abc",
command: "setGridValue",
columnID: "23"
}]
Since the JSON data maintains a consistent order, I can easily extract values and format them into separate objects within the gridinsert:[]
structure for each original object.