Last active
October 3, 2018 03:41
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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