Last active
November 4, 2016 17:19
-
-
Save tanyagupta/41bb957b1c7ae5ebabfba3743df262c6 to your computer and use it in GitHub Desktop.
Accessing heterogenous JSON data (smarter way) - Part 2
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
//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