Skip to content

Instantly share code, notes, and snippets.

@DDynamic
Last active October 3, 2018 03:41
Show Gist options
  • Save DDynamic/d451031b7f170444691c9284b0387c9d to your computer and use it in GitHub Desktop.
Save DDynamic/d451031b7f170444691c9284b0387c9d to your computer and use it in GitHub Desktop.
Google Sheets read JSON function. Read values from a JSON array in another cell using a key.
function READJSON(input, key) {
if (input.map) {
return input.map(function(input) {
return READJSON(input, key)
});
} else {
if (input || 0 !== input.length) {
var value = key.split('.').reduce(function(a, b) {
return a[b] || "";
}, JSON.parse(input));
if (!isNaN(Number(value)) && value) {
return Number(value);
} else {
return value;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment