Skip to content

Instantly share code, notes, and snippets.

@GoSubRoutine
Last active November 8, 2019 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GoSubRoutine/7a567f0510b338b6d0fc1ef53f24f10e to your computer and use it in GitHub Desktop.
Save GoSubRoutine/7a567f0510b338b6d0fc1ef53f24f10e to your computer and use it in GitHub Desktop.
JSON Open-Notify ISS
height: 200
{ "number": 6, "message": "success",
"people": [
{ "craft": "ISS", "name": "Peggy Whitson" },
{ "craft": "ISS", "name": "Fyodor Yurchikhin" },
{ "craft": "ISS", "name": "Jack Fischer" },
{ "craft": "ISS", "name": "Sergey Ryazanskiy" },
{ "craft": "ISS", "name": "Randy Bresnik" },
{ "craft": "ISS", "name": "Paolo Nespoli" }
]
}
<script async src=http://cdn.JsDelivr.net/npm/p5></script>
<script defer src=sketch.js></script>
/**
* JSON Open-Notify ISS (v3.0)
* GoToLoop (2017-May-06)
*
* https://Forum.Processing.org/two/discussion/22414/
* trouble-loading-json-data-from-a-url#Item_7
*
* http://Bl.ocks.org/GoSubRoutine/7a567f0510b338b6d0fc1ef53f24f10e
*/
"use strict";
const HTTP = 'http' + '://',
SITE = 'api.Open-Notify.org/',
FILE = 'astros.json',
REMOTE = true,
PATH = REMOTE && HTTP + SITE + FILE || FILE,
COLOR = 'OrangeRed';
let jsonObject;
function preload() {
jsonObject = loadJSON(PATH, print);
}
function setup() {
noCanvas(), noLoop();
const astroArray = jsonObject.people,
len = astroArray.length,
issCrewNames = Array(len),
ol = createElement('ol');
ol.style('color', COLOR)
.style('font-weight: bold')
.style('font-size: 1.2em');
for (let i = 0; i < len; issCrewNames[i] = astroArray[i++].name);
print(issCrewNames);
for (const crew of issCrewNames) createElement('li', crew).parent(ol);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment