Preview

04 - JSON and XML Comparison

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

  typical search engines used for communicating

  standard methods for transferring data

  methods for detecting IP addresses and connecting to the internet

  file formats used to block unauthorised communication

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

  FALSE

  TRUE

 3. The features of JSON include:

  it is easy for a human to read

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

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

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

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

  FALSE

  TRUE

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

  FALSE

  TRUE

 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 an employees object, with an array of 3 employees

  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

 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

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

  Both can be parsed and used by different programming languages

 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.

  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

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

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

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

  delete

  parse (parsing generally means interpreting)

  define (create or decide a definition for)

  upload

 10. JSON is parsed into a ____________________________

  finite set of bits

  ready-made XML formatted sheet

  ready-to-use JavaScript object

  CPU (directly)

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

  TRUE

  FALSE

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

  binary tree

  dictionary

  tuple

  variable

 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++

  JavaScript

  HTML

  Java

 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

  an address

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

  a person

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

  TRUE

  FALSE