程序代写CS代考 python javascript database Java Semester 2 2021 – cscodehelp代写
Semester 2 2021
Lecture 3, Part III: Data Formats – Semi-structured format: JSON
Semi-structured Data – JSON
JSON
JavaScript Object Notation (JSON)
• JSON (www.json.org)
• (pretty much alone)
• c.f the development of XML by committee
• “Javascript: the good parts” • O’ Reilly, Yahoo Press
JSON syntax rules
• Object data is in name/value pairs “firstName”:”John”
• JSON values
•A number (integer or floating point)
•A string (in double quotes) •A Boolean (true or false)
•An array (in square brackets) •An object (in curly braces) •null
JSON syntax rules
• JSON Objects {“firstName”:”John”,
“lastName”:”Doe”}
• JSON Arrays “employees”:[
{“firstName”:”John”, “lastName”:”Doe”}, {“firstName”:”Anna”, “lastName”:”Smith”}, {“firstName”:”Peter”, “lastName”:”Jones”}
]
• These objects repeat recursively down a hierarchy as needed. • In terms of syntax that’s pretty much it!
JSON format (from json.org)
Verbosity
Python libraries for JSON and XML
• json • lxml
XML, JSON, CSV and HTML conversion tools
JSON compared to XML
• JSON is simpler and more compact/lightweight than XML; easy to parse.
• Which appeals to programmers looking for speed and efficiency
• Widely used for storing data in noSQL databases
• Common JSON application – read and display data from a webserver using javascript. https://www.w3schools.com/js/js_json.asp
• XML comes with a large family of other standards for querying and transforming (XQuery, XML Schema, XPATH, XSLT, namespaces, …)
• allows formal validation
• makes you consider the data design more closely
JSON: Summary
• JavaScript Object Notation
• Lightweight, streamlined, standard method of data exchange
• Originally designed to speed up client/server interactions: • By running in the client browser
• Can be used to represent any kind of semi structured data • Lacks context and schema definitions