Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

121
Views
Get key element in an object when key is a string containing spaces

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,

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!