Last active
November 4, 2016 17:20
-
-
Save tanyagupta/33aa2692d130a0c5bec8c91502c11c1e to your computer and use it in GitHub Desktop.
Accessing heterogenous JSON data (inefficient way) - Part 1
This file contains 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
//Note that this is an INEFFICIENT way to solve the problem | |
function noob_way() { | |
// get test data from a test data utility | |
var cars=get_data_set("basic"); | |
for (var i in cars){ | |
if(cars[i]["model"]!==undefined) { | |
Logger.log(cars[i]["model"]); // Logger.log() is Google App Script's console.log | |
} | |
if(cars[i]["trim"]!==undefined) { | |
Logger.log(cars[i]["trim"]); // Logger.log() is Google App Script's console.log | |
} | |
if(cars[i]["year"]!==undefined) { | |
Logger.log(cars[i]["year"]); // Logger.log() is Google App Script's console.log | |
} | |
if(cars[i]["wheel"]!==undefined) { | |
Logger.log(cars[i]["wheel"]); | |
if(cars[i]["wheel"]["wheel_size"]!==undefined){ | |
Logger.log(cars[i]["wheel"]["wheel_size"]); // Logger.log() is Google App Script's console.log | |
} | |
if(cars[i]["wheel"]["wheel_metal"]!==undefined){ | |
Logger.log(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