For the complete documentation index, see llms.txt. This page is also available as Markdown.

Week 08

Data

JSON (JavaScript Object Notation)

{
  "title": "Oldboy",
  "director": "Park Chan-wook",
  "year": 2003,
  "rating": 8.4
}
{
  "firstName": "John",
  "lastName": "Smith",
  "age": 25,
  "address": {
    "streetAddress": "21 2nd Street",
    "city": "New York",
    "state": "NY",
    "postalCode": "10021"
  },
  "phoneNumber": [
    {
      "type": "home",
      "number": "212 555-1234"
    },
    {
      "type": "fax",
      "number": "646 555-4567"
    }
  ],
  "gender":{
    "type":"male"
  }
}

We have played with JSON already.......

When we access the values in the JSON object.

https://editor.p5js.org/kdoodoo/sketches/HkMKXi42Q

Let's make your own .json file.

food.json

Let's validate

https://jsonlint.com/

https://editor.p5js.org/kdoodoo/sketches/Hk-YisNnm

JSON with [Array]

https://github.com/dariusk/corpora/tree/master/data

We use AAA.BBB[ i ]

i as an index

https://editor.p5js.org/kdoodoo/sketches/B1Gxvn42m

API (Application programming interface)

It can be anything like CSV, XML, TXT, PDF but we want "JSON!"

Why?? J = Javascript

JSON VIEWER

Before >>>

After >>>

https://samples.openweathermap.org/data/2.5/forecast?q=M%C3%BCnchen,DE&appid=b6907d289e10d714a6e88b30761fae22

Simple API example

Sign Up here:

https://openweathermap.org/appid

Try it here: Weather in London:

https://samples.openweathermap.org/data/2.5/weather?q=London,uk

?q=london,uk

?q=london,uk& ________ = ________ &________=_________

https://samples.openweathermap.org/data/2.5/weather?q=London,uk&appid=e4d37ccc2c4f3977c2e466fa78b38fcb

&units=metric

?lat=35&lon=139

https://editor.p5js.org/kdoodoo/sketches/HJfYl643m

Assignment

https://goo.gl/forms/lZGI0Nf5iW6GT1ei1

Last updated