Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Process and display zoo.json

View processAndDisplayZooJSON.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
args.setPromise(WinJS.UI.processAll().then(function() {
//build up the URL for the file added to the project
var url = new Windows.Foundation.Uri("ms-appx:///zoo.json");
 
//this will store the imported data
var myNewAnimals = new Array();
 
//invoke the static method which loads the file
//and creates Animal objects from json data
//THE METHOD RETURNS A PROMISE!!!
Zoo.Animal.loadZoo(url).done(
 
function (result) {
myNewAnimals = result;
 
myNewAnimals.forEach(function (animal) {
console.log("Name: " + animal.getName() + ", Age: " + animal.getAge() + ", IsHungry: " + animal.isHungry() + ", Hours since Last feed: " + animal.getHoursSinceLastFeed());
});
},
function (error) {
var messDialog = new Windows.UI.Popups.MessageDialog(error);
messDialog.showAsync();
});
 
}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.