JSON

Her er et eksempel på noget lidt lummert JSON

 var data;
var gymnasieelev;
let container
function preload() {
//Så henter vi hele vores JSON objekt ind i variablen
//data = loadJSON('birds_antarctica.json');
gymnasieelever = [{ "absence": "20%", "name": "Karsten", "grades": 6, "drunkAtLastParty": "yes", "happyToday": "yes", "gender": "cis white male", "friends" : [] }, { "absence": "30%", "name": "Signe", "grades": 2, "drunkAtLastParty": "very much so", "happyToday": "nope", "gender": "queer multitrans personality spirit", "friends" : [] }]
}
function setup() {
gymnasieelever[0].friends.push(gymnasieelever[1]);
console.log(gymnasieelever);
printElev(gymnasieelever[0]); function printElev(o) { container = createElement("section"); createElement("h2", o.name).parent(container); createElement("li", "Karaktergennemsnit: " + o.grades).parent(container); createElement("li", "Fuld til sidste fest: " + o.drunkAtLastParty).parent(container); createElement("li", "Lykkelig i dag?: " + o.happyToday).parent(container); } //container.hide();
}

Leave a comment