Google Apps Script : Returning "null" when trying to select a specific object in a API response but I can see it in the original response Google Apps Script : Returning "null" when trying to select a specific object in a API response but I can see it in the original response json json

Google Apps Script : Returning "null" when trying to select a specific object in a API response but I can see it in the original response


From your question and script,

  • If the value of This is the JSON data I receive back...in a pretty print visualized format. is the value of JSON.stringify(parsedData), parsedData.gram_in_mad returns 548.0454.

  • But if the value of This is the JSON data I receive back...in a pretty print visualized format. is the value of parsedData, I thought that in the case of response of var response = UrlFetchApp.fetch(url,params);, parsedData might be the string even when var parsedData = JSON.parse(response.getContentText()); is used.

So how about the following modification?

From:

var parsedData = JSON.parse(response.getContentText());

To:

var parsedData = JSON.parse(JSON.parse(response.getContentText()));