I have a json file with content similar to the following
{
"dlg-4b2edcfb-7fa5-4a93-a82e-8a6637fb5d7a": [
{
"utteranceID": 0,
"speaker": "agent",
"source": "[UFT]HI, how can i help you?",
"target": "[UFT]",
"input formality tone": "unacceptable"
},
{
"utteranceID": 1,
"speaker": "customer",
"source": "Hi, could you help me with ordering from Starbucks?",
"target": "[UFT]",
"input formality tone": "unacceptable"
}
]
}
I need to extract values from the key "input formality tone".
I already tried this code, but it returns null
as result
function test() {
var file = DriveApp.getFileById("19ncMpYna8VEBCVfvMjbuImFZXPx2Jlw0");
var filecontent = file.getBlob().getDataAsString();
var jsonparse = JSON.parse(filecontent);
for (var key in jsonparse) {
var arr = jsonparse[key];
for (var i=0; i<arr.length; i++) {
var item = arr[i];
Logger.log(item)
inputFormalityTone = "input formality tone";
Logger.log(item.inputFormalityTone)
}
}
}
Can you please help me to solve this? Thanks in advance,