- Forward


JavaScript Object Notation (JSON)
An Introduction


Prof. David Bernstein
James Madison University

Computer Science Department
bernstdh@jmu.edu

Print

Motivation
Back SMYC Forward
  • Origins:
    • A subset of the JavaScript/ECMAScript programming language for defining objects literals
  • What is JSON Now?
    • A language-independent way of marking up hierarchical data (a.k.a., a data interchange format)
Elements
Back SMYC Forward
  • Values:
    • Numbers
    • Strings (must be within double quotes)
    • false/true
    • null
  • Name-Value Pairs:
    • name:value
  • Objects:
    • { nvp [,nvp...] }
  • Arrays:
    • [ element [,element...] ]
Identifying JSON Files
Back SMYC Forward
  • An Issue:
    • How can we distinguish a JSON file from a JavaScript/ECMAScript file?
  • The Solution:
    • Use the MIME type application/json
An Example
Back SMYC Forward

A Single Object

jsonexamples/basics/person.json
 
An Example
Back SMYC Forward

An Array of Objects

jsonexamples/basics/incidents.json
 
There's Always More to Learn
Back -