user interaction: xml and jsondjp3/classes/2010_09_inf133/... · •xml is like a ferrari •json...
TRANSCRIPT
![Page 1: User Interaction: XML and JSONdjp3/classes/2010_09_INF133/... · •XML is like a Ferrari •JSON is like a good bicycle •A Ferrari will get you to Las Vegas faster •A bicycle](https://reader033.vdocuments.us/reader033/viewer/2022051915/6006ca506f40346705380b74/html5/thumbnails/1.jpg)
User Interaction:XML and JSON
Asst. Professor Donald J. PattersonINF 133 Fall 2010
1Thursday, October 7, 2010
![Page 2: User Interaction: XML and JSONdjp3/classes/2010_09_INF133/... · •XML is like a Ferrari •JSON is like a good bicycle •A Ferrari will get you to Las Vegas faster •A bicycle](https://reader033.vdocuments.us/reader033/viewer/2022051915/6006ca506f40346705380b74/html5/thumbnails/2.jpg)
Web-based Data Exchange Formats
HTML
XMLXHTML JSON
Thursday, October 7, 2010
![Page 3: User Interaction: XML and JSONdjp3/classes/2010_09_INF133/... · •XML is like a Ferrari •JSON is like a good bicycle •A Ferrari will get you to Las Vegas faster •A bicycle](https://reader033.vdocuments.us/reader033/viewer/2022051915/6006ca506f40346705380b74/html5/thumbnails/3.jpg)
• XML is like a Ferrari
• JSON is like a good bicycle
• A Ferrari will get you to Las Vegas faster
• A bicycle can go off-road
• XML is beautiful and powerful
• XML is well-engineered and well-researched
• JSON is much lighter weight
• JSON is easier to just get going fast
XML vs JSON
Thursday, October 7, 2010
![Page 4: User Interaction: XML and JSONdjp3/classes/2010_09_INF133/... · •XML is like a Ferrari •JSON is like a good bicycle •A Ferrari will get you to Las Vegas faster •A bicycle](https://reader033.vdocuments.us/reader033/viewer/2022051915/6006ca506f40346705380b74/html5/thumbnails/4.jpg)
• XML is like a Ferrari
• JSON is like a good bicycle
• A Ferrari will get you to Las Vegas faster
• A bicycle can go off-road
• XML is beautiful and powerful
• XML is well-engineered and well-researched
• JSON is much lighter weight
• JSON is easier to just get going fast
XML vs JSON
Thursday, October 7, 2010
![Page 5: User Interaction: XML and JSONdjp3/classes/2010_09_INF133/... · •XML is like a Ferrari •JSON is like a good bicycle •A Ferrari will get you to Las Vegas faster •A bicycle](https://reader033.vdocuments.us/reader033/viewer/2022051915/6006ca506f40346705380b74/html5/thumbnails/5.jpg)
• XML is like a Ferrari
• JSON is like a good bicycle
• A Ferrari will get you to Las Vegas faster
• A bicycle can go off-road
• XML is beautiful and powerful
• XML is well-engineered and well-researched
• JSON is much lighter weight
• JSON is easier to just get going fast
XML vs JSON
Thursday, October 7, 2010
![Page 6: User Interaction: XML and JSONdjp3/classes/2010_09_INF133/... · •XML is like a Ferrari •JSON is like a good bicycle •A Ferrari will get you to Las Vegas faster •A bicycle](https://reader033.vdocuments.us/reader033/viewer/2022051915/6006ca506f40346705380b74/html5/thumbnails/6.jpg)
• JSON is like XML
• They are both human-readable text
• They are both hierarchical/ tree-structured
• Both can be parsed and used in many languages
• Both can be passed in AJAX requests
• (despite the X in AJAX)
• Both have matching opening and closing symbols
JSON vs XML http://www.secretgeek.net/json_3mins.asp
Thursday, October 7, 2010
![Page 7: User Interaction: XML and JSONdjp3/classes/2010_09_INF133/... · •XML is like a Ferrari •JSON is like a good bicycle •A Ferrari will get you to Las Vegas faster •A bicycle](https://reader033.vdocuments.us/reader033/viewer/2022051915/6006ca506f40346705380b74/html5/thumbnails/7.jpg)
• JSON is different than XML
• JSON does not have tags
• JSON is less verbose
• quicker to write
• quicker to read
• quicker to transport
• JSON can be parsed trivially using the eval() procedure in Javascript
• JSON has arrays, XML does not
• XML is extensible JSON usually isn’t
• new versions can coexist with legacy versions
JSON vs XML http://www.secretgeek.net/json_3mins.asp
Thursday, October 7, 2010
![Page 8: User Interaction: XML and JSONdjp3/classes/2010_09_INF133/... · •XML is like a Ferrari •JSON is like a good bicycle •A Ferrari will get you to Las Vegas faster •A bicycle](https://reader033.vdocuments.us/reader033/viewer/2022051915/6006ca506f40346705380b74/html5/thumbnails/8.jpg)
• Using either works like this:
• get the JSON/XML string
• convert it to a data structure
• JSON -> eval()
• XML -> some parse function (lib dependent)
• use the data
• Do not process either type of data by “hand”.
• input: Use a library to parse the data
• output:
• Create the data in native data structures
• Use a program or method to output the data structure in JSON/XML
JSON vs XML http://www.secretgeek.net/json_3mins.asp
Thursday, October 7, 2010
![Page 9: User Interaction: XML and JSONdjp3/classes/2010_09_INF133/... · •XML is like a Ferrari •JSON is like a good bicycle •A Ferrari will get you to Las Vegas faster •A bicycle](https://reader033.vdocuments.us/reader033/viewer/2022051915/6006ca506f40346705380b74/html5/thumbnails/9.jpg)
Example
class
INF 221
program
"search engine"
INF 133
quiz
"Crossword puzzle"
Assignment
XML
• Represent this as
• XML
• JSON
• There is not an absolutely correct answer to how to interpret this tree in the respective languages.
• There are multiple ways to interpret what this tree means.
Thursday, October 7, 2010
![Page 10: User Interaction: XML and JSONdjp3/classes/2010_09_INF133/... · •XML is like a Ferrari •JSON is like a good bicycle •A Ferrari will get you to Las Vegas faster •A bicycle](https://reader033.vdocuments.us/reader033/viewer/2022051915/6006ca506f40346705380b74/html5/thumbnails/10.jpg)
Example
class
INF 221
program
"search engine"
INF 133
quiz
"Crossword puzzle"
Assignment
XML
Thursday, October 7, 2010
![Page 11: User Interaction: XML and JSONdjp3/classes/2010_09_INF133/... · •XML is like a Ferrari •JSON is like a good bicycle •A Ferrari will get you to Las Vegas faster •A bicycle](https://reader033.vdocuments.us/reader033/viewer/2022051915/6006ca506f40346705380b74/html5/thumbnails/11.jpg)
Example
class
INF 221
program
"search engine"
INF 133
quiz
"Crossword puzzle"
Assignment
XML
Thursday, October 7, 2010
![Page 12: User Interaction: XML and JSONdjp3/classes/2010_09_INF133/... · •XML is like a Ferrari •JSON is like a good bicycle •A Ferrari will get you to Las Vegas faster •A bicycle](https://reader033.vdocuments.us/reader033/viewer/2022051915/6006ca506f40346705380b74/html5/thumbnails/12.jpg)
Thursday, October 7, 2010