@Matt Heagerty Thank you for sharing the details offline. I will share the sample codes here.
e.g. 1( input JSON payload):
index.js
module.exports = async function (context, req) {
context.bindings.outputDocument =[];
for(let i = 0, len=req.body.length; i<len;i++){
const doc = req.body[i];
context.bindings.outputDocument.push(doc);
}
OR
req.body.forEach(message =>{
const doc = message;
context.bindings.outputDocument.push(doc);
});
context.done();
};
sample payload:
[
{
"id":"1",
"name": "Jaya",
"surname": "Chatterjee"
},
{
"id":"2",
"name": "Matt",
"surname": "Heagerty"
}
]
In this particular scenario, we have tested with a similar structure :
module.exports = async function (context, req) {
context.log('JavaScript HTTP trigger function processed a request.');
context.bindings.outputDocument = JSON.stringify([{
id: "record_3",
tag: "Count",
value: "some value 3"
}, {
id: "record_4",
tag: "Count",
value: "some value 4"
}, {
id: "record_5",
tag: "Count",
value: "some value 5"
}, {
id: "record_6",
tag: "Count",
value: "some value 6"
}]);
context.done();
}
It works fine. So we would suggest you to form the objects first and then run the stringify function once , not in a loop.
If you think this helped, please "accept the answer" and " up-vote" so that this could help others in the community.