Preview

04 - JSON and XML Comparison

 1. JSON and XML are the two _________________________________________________ between the server and the web application.

  standard methods for transferring data

  file formats used to block unauthorised communication

  methods for detecting IP addresses and connecting to the internet

  typical search engines used for communicating

 2. XML uses curly braces as part of its format and JSON uses angle brackets.

  TRUE

  FALSE

 3. The features of JSON include:

  It is easier to create and easier for computers to parse/quicker to parse

  it is easy for a human to read

  All of the above options are valid features/advantags of JSON

  it is compact (arguably more compact and concise than XML)

 4. The syntax and structure of JSON is simple and straightforward however, it does not allow the use of arrays.

  TRUE

  FALSE

 5. Both JSON and XML can be used to receive data from a web server

  TRUE

  FALSE

 6. Which of the following examples of JSON and what is the example actually doing?
Example 1
==========

{"employees":[
    { "firstName":"John", "lastName":"Doe" },
    { "firstName":"Anna", "lastName":"Smith" },
    { "firstName":"Peter", "lastName":"Jones" }
]}

Example 2
==========
<employees>
    <employee>
        <firstName>John</firstName> <lastName>Doe</lastName>
    </employee>
    <employee>
        <firstName>Anna</firstName> <lastName>Smith</lastName>
    </employee>
    <employee>
        <firstName>Peter</firstName> <lastName>Jones</lastName>
    </employee>
</employees>

  The second example of JSON and it defines an employees object with an array of three names

  The first example is JSON and it defines a single array with one object (i.e name) in it.

  The second example is JSON and it defines a 'Name' object with three names

  The first example is JSON and it defines an employees object, with an array of 3 employees

 7. JSON is like XML for the following reason …..

  They are both 'self describing' - this means they are human readable

  All of the above options are valid similarities between JSON and XML

  Both can be parsed and used by different programming languages

  They are both heirarchical (values within values) and can be fetched with an XMLHttpRequest

 8. Which of the following in the list are differences between JSON and XML?
JSON doesn't use end tag
JSON is self describing - human readable
JSON is shorter
JSON can be fetched with an XMLHttpRequest
JSON is quicker to read and write
JSON can use arrays
XML has to be parsed with an XML parser. 
JSON can be parsed by a standard JavaScript function.

  The only valid difference on the list is the fact that JSON doesn't use an end tag. Otherwise, they are completely alike.

  All of them except for Point 1, Point 2, Point 3, and Point 6

  All of them, except Point 2. and Point 4.

  The only valid differences between JSON and XML are the fact that JSON is shorter and can use arrays

 9. The general consensus/agreement is that XML is much more difficult to _________ than JSON

  parse (parsing generally means interpreting)

  define (create or decide a definition for)

  delete

  upload

 10. JSON is parsed into a ____________________________

  ready-made XML formatted sheet

  finite set of bits

  ready-to-use JavaScript object

  CPU (directly)

 11. Generally speaking, XML is considered more 'lightweight' than JSON

  FALSE

  TRUE

 12. JSON is built on two structures - one of them is similar to a _____________ in python. (a collection of key or name/value pairs)

  dictionary

  variable

  binary tree

  tuple

 13. JSON is a language-independent data format. It was derived from ___________ but as of 2017 many programming languages include code to generate and parse JSON-format data

  C++

  Java

  HTML

  JavaScript

 14. What is the following JSON 'snippet' describing?
{
  "firstName": "John",
  "lastName": "Smith",
  "isAlive": true,
  "age": 27,
  "address": {
    "streetAddress": "21 2nd Street",
    "city": "New York",
    "state": "NY",
    "postalCode": "10021-3100"
  },
  "phoneNumbers": [
    {
      "type": "home",
      "number": "212 555-1234"
    },
    {
      "type": "office",
      "number": "646 555-4567"
    },
    {
      "type": "mobile",
      "number": "123 456-7890"
    }
  ],
  "children": [],
  "spouse": null
}

  a single data type

  a person

  an address

  an array of different objects, e.g. addresses, humans, mobiles

 15. JSON stands for JavaScript Object Notation and it’s a data format.

  TRUE

  FALSE