I'm working on GCP Document AI using Node.js and react.js, In the given code I have created JSON structure (var jsonResult
) then in for loop I get all the different key and text value data only if I do console.log(key);
and console.log(textValue);
but I want to store all those data as JSON, then I want to send that JSON as response using Node.js snippet res.json(JSON.stringify(jsonResult));
.
var jsonResult = [{
key:" ",
value:" "
}];
console.log('Document processing complete.');
const {document} = result;
for (let i=0;i<document.entities.length;i++)
{
var key = document.entities[i].type;
var textValue = document.entities[i].textAnchor !== null ? document.entities[i].textAnchor.content : '';
// console.log(key);
// console.log(textValue);
jsonResult[i].key = key;
jsonResult[i].textValue = textValue;
}
res.json(JSON.stringify(jsonResult));