Skip to content

Instantly share code, notes, and snippets.

@tanyagupta
Last active November 4, 2016 17:19
Show Gist options
  • Save tanyagupta/41bb957b1c7ae5ebabfba3743df262c6 to your computer and use it in GitHub Desktop.
Save tanyagupta/41bb957b1c7ae5ebabfba3743df262c6 to your computer and use it in GitHub Desktop.
Accessing heterogenous JSON data (smarter way) - Part 2
//Smarter way to access the data
function noob_smart_way(){
var cars=get_data_set("basic");
var format_string = "%s %s %s %s %s";
for (var i in cars){
Logger.log(format_string, cars[i]["model"] || "",cars[i]["trim"] || "",cars[i]["year"] || "",
cars[i]["wheel"] && cars[i]["wheel"]["wheel_size"] || "",
cars[i]["wheel"] && cars[i]["wheel"]["wheel_metal"] || "")
// Logger.log() is Google App Script's console.log
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment