Skip to content

Instantly share code, notes, and snippets.

@h4tr3d
Last active September 18, 2024 04:38
Show Gist options
  • Save h4tr3d/6a2d4bbbfdc9f32e9aa14307b7243430 to your computer and use it in GitHub Desktop.
Save h4tr3d/6a2d4bbbfdc9f32e9aa14307b7243430 to your computer and use it in GitHub Desktop.
Google SpreadSheet JSON processing
// Based on: https://stackoverflow.com/a/76915043/1828241
// 1. Open Spread Sheet
// 2. Go Menu → Extensions → App Scripts
// 3. Create new script, rename it to JsonData.gs
// 4. Put this code, save
// 5. Return back to Spread Sheet, entry formula as usial: `=JsonData(A1; "field_name")`
// For compres JSON and nested fields script must be adjusted
function JsonData(jsonText, key) {
try {
var data = JSON.parse(jsonText);
return data[key] || "";
} catch (error) {
return "";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment