Skip to content

Instantly share code, notes, and snippets.

@timabell
Created August 29, 2013 10:31
Show Gist options
  • Select an option

  • Save timabell/6376528 to your computer and use it in GitHub Desktop.

Select an option

Save timabell/6376528 to your computer and use it in GitHub Desktop.
// list services defined in fixture data
var fs = require('fs');
var files = fs.readdirSync('.').filter(function(c){return c.match(/\.json$/)});
files.forEach(function(json) {
console.log('File: ' + json);
var country = require('./' + json);
if (!country.results) {
console.log(" - No data");
console.log();
return;
}
// console.log(country);
country.results.forEach(function(org){
console.log(' - Org: ' + org.title);
if (org.offices.main) {
console.log(' Main: ' + org.offices.main.title);
logServices(org.offices.main.services)
} else {
console.log(' Main: none');
}
if (org.offices.other.length > 0) {
org.offices.other.forEach(function(office) {
console.log(' Office: ' + office.title);
logServices(office.services)
});
}
console.log();
});
});
function logServices(services){
if (services.length > 0) {
services.forEach(function(service) {
console.log(' - ' + service.title);
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment