JSON - PowerPoint PPT Presentation

About This Presentation
Title:

JSON

Description:

Now x is more like ? Whatever that's appropriate. XML has its advantages and disadvantages ... More convenient processing functions are sprouting up ... – PowerPoint PPT presentation

Number of Views:6429
Avg rating:3.0/5.0
Slides: 14
Provided by: venkatsub
Learn more at: https://www2.cs.uh.edu
Category:
Tags: json | sprouting

less

Transcript and Presenter's Notes

Title: JSON


1
JSON
2
Does Ajax need XML?
  • The X in Ajax once stood for XML
  • Now x is more like ? Whatever thats appropriate
  • XML has its advantages and disadvantages
  • Very expressive, but too noisy, large, slow

3
JSON
  • JavaScript Object Notation
  • It is intended to be minimal
  • It is a textual notation of data
  • JavaScript is a superset of JSON
  • YAML is a superset of JSON
  • YAML decoder and JavaScript interpreter can be
    used as JSON decoder

4
Whats in JSON
Source httpwww/json.org
5
String
  • Strings
  • Any double quoted Unicode character
  • Double quote escaped using \
  • Empty string represented by ""

Source httpwww/json.org
6
Number
  • Numbers
  • Integer, real, scientific
  • Use null for invalid/infinity

Source httpwww/json.org
7
Object
  • Objects More of a hashmap notation
  • "keyname" JSONValue, "keyname" JSONValue,
  • JSONValue may be any of the JSON value types
    including other objects

Source httpwww/json.org
8
Arrays
  • Arrays
  • Sequence of values
  • JSONValue, JSONValue, JSONValue,
  • Index is decided by implementation (like Java can
    use 0, VB can use 1, JSON doesnt care)
  • JSONValue may be any JSON value type including
    objects and arrays

Source httpwww/json.org
9
Using JSON to Populate a Page
10
Concerns with eval
  • eval sends the JSON text (or any text) to the
    Java compiler
  • May not be safe
  • Use only if trusted source
  • Whats the alternative
  • parseJSON only parses JSON text

11
parseJSON
  • Available from http//www.json.org/json.js
  • Parses only JSON text and is fast

12
Convert to JSON
  • toJSONString() converts an object to JSON

13
More Convenience
  • More convenient processing functions are
    sprouting up
  • There is also proposal for JSONRequest object to
    be standardized by browsers
  • http//json.org/JSONRequest.html
Write a Comment
User Comments (0)
About PowerShow.com