To achieve the desired result of extracting JSON from a proprietary content management system, transforming it into a CSV, and depositing that CSV in an Office 365 shared drive, a combination of Azure Function and Azure Logic App is utilized. The Node/JavaScript Azure Function successfully retrieves the JSON object and sends it to the Azure Logic App for further processing.
The Logic App includes a built-in JSON-to-CSV "action" that requires the input to be in an array format.
Despite various attempts, converting the JSON object into an array has been unsuccessful. Experimentation with tools like node-jq and Lodash have not yielded the desired outcome.
Original JSON:
[
{
"Challenge": {
"Group": {
"Name": "Challenge group name"
}
},
"Name": "Name",
...
<99 more>
]
Desired result:
Modifications required on specific keys within the array for better readability.
[
{
"Group": "Challenge group name" (equivalent to Challenge.Group.Name),
"Title": "Name" (equivalent to Name),
...
<99 more>
]
Azure Function code
A sample implementation using Azure Function and related dependencies for data extraction and transmission operations.
(Detailed code example omitted)
Failed attempts (a small number)
Attempt
var flat = _.flatMap(result, 'Name');
Result
["123","456","789","012","345",<etc>]
Attempt
const arr = (result, keyAs) => _.values(_.mapValues(result, (value, key) => { value[keyAs] = key; return value; }));
Result
undefined
Attempt
result.blocks = _(result.blocks)
.map('Name')
.value();
Result
result is not defined
Attempt
_.map(info, (obj, key) => {
obj.symbol = key
return obj
})
Result
No discernible effect observed.
Note: As a non-professional coder seeking assistance, any guidance or support is greatly appreciated.