1<?php
2 // JSON string
3 $someJSON = '[{"name":"Jonathan Suh","gender":"male"},{"name":"William Philbin","gender":"male"},{"name":"Allison McKinnery","gender":"female"}]';
4
5 // Convert JSON string to Object
6 $someObject = json_decode($someJSON);
7 echo $someObject[0]->name; // Access Object data
8?>
9
1<?php
2
3$data = '{
4 "name": "Aragorn",
5 "race": "Human"
6}';
7
8$character = json_decode($data);
9echo $character->name;