Skip to content

@gergob /processAndDisplayZooJSON.js
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Process and display zoo.json
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.