JSON Examples

5- JSON Notation

Output

JS

// notice this is an array of objects
var People = [
    {
        "firstName":  "Joe",
        "midName":    "Alan",
        "lastName":   "Dokes",
        "age": "35"
    },
    {
        "firstName":  "Sally",
        "midName":    "Mae",
        "lastName":   "Linkhouse",
        "age": "24"
    },
    {
        "firstName":  "Bobby",
        "midName":    "Jessie",
        "lastName":   "Sturmgard",
        "age": "48"
    }
]

HTML

<script>
    document.getElementById('info').innerHTML = 
        'First: ' + People[0].firstName + '<br>' +
        'Last: ' + People[0].lastName;
</script>