Messing Around with JSON

JSON from a URL (Object Method)

Working off this tutorial.

A JSON file:

[ { "name": "Aragorn", "race": "human" }, { "name": "Gimli", "race": "dwarf" } ]

A foreach loop:

A table:

Name Race
Aragorn human
Gimli dwarf

JSON from a URL (Associative Array Method)

The JSON as an array:

Array ( [0] => Array ( [name] => Aragorn [race] => human ) [1] => Array ( [name] => Gimli [race] => dwarf ) )

A foreach loop this way:

Characters

Nested JSON

Another JSON file:

[ { "name": "Harry Potter", "wand": [ { "core": "phoenix feather", "length": "11 inches", "wood": "holly" } ] }, { "name": "Hermione Granger", "wand": [ { "core": "dragon heartstring", "length": "10 and 3/4 inches", "wood": "vine" } ] } ]

Harry Potter

Hermione Granger