PLAY READ BLOG

Assess your experience with JSON

I estimate it would take you 44 steps in 14 minutes to Assess your experience with JSON.
Which streaming format is the following JSON stream of objects an example of?
{"id": "1", "name": "one"}{"id": "2", "name": "two"}{"id": "3", "name": "three"}
  • Length-prefixed
  • Frame-delimited
  • Concatenated
  • Line-delimited
What is one possible disadvantage of using the JSON API specification?
  • It can only be implemented with the Express.js API.
  • There are only clients for JavaScript and Ruby.
  • It forces you to make multiple calls to get related data.
  • It can be restrictive and opinionated.
What is the best way to represent an ordered collection of key-value pairs in JSON?
  • a single array with interleaved keys and values.
  • an array of objects, each containing a single key-value pair.
  • an object containing the key-value pairs.
  • two arrays: one for keys, and another one for values.
Does JSON support efficient encoding of binary data?
1. Yes, via CDATA sections.

2. No, binary data isn't allowed in JSON documents in any form.

3. No, although it's possible to encode binary data in strings with Base64 or the like.

4. Yes, via the "b" prefix on string values.
  • 1.
  • 2.
  • 3.
  • 4.
How can you insert comments into a JSON document?
1. It isn't possible as JSON doesn't support comments

2. Using // to indicate that the following characters are a comment

3. Using /* */ as comment delimiters for a single line or multiline block

4. Using -- at the start of a line to mark it as a comment line
  • 1.
  • 2.
  • 3.
  • 4.
What kind of values can JSON arrays contain?
1. Values of any supported type, as well as null

2. Values of any supported type, as long as ALL of them have the same type

3. Values of any supported type, except arrays

4. Only booleans, numbers, strings, or null
  • 1.
  • 2.
  • 3.
  • 4.
What is a valid reason for needing to convert a JSON object to a string?
1. To separate key/value pairs into a string array

2. To enable sending JSON data to a web server

3. To find the value of a particular key

4. To find a string value within the JSON object using the indexOf() method
  • 1.
  • 2.
  • 3.
  • 4.
Which of the following subschema examples below allows you to validate data to ensure that only string and number values are given?
1.
{
"allOf": [
{ "type": "string" },
{ "minValue": 0 }
]}

2.
{
"anyOf": [
{ "type": "string" },
{ "type": "number" }
]}

3.
{
"oneOf": [
{ "type": "number" },
{ "type": "object" }
]}

4.
{
"onlyOne": [
{ "type": "string" },
{ "type": "number" }
]}
  • 1.
  • 2.
  • 3.
  • 4.
A client has included the JSON API media type in the header and sends a GET request to a server endpoint. What must be included in the header at least once?
  • Accept: text/html
  • Accept: application/vnd.api+json
  • Accept-Encoding: api+json
  • Accept: application/xhtml+json
What is the problem with the following JSON document?

{
orderNo: 1235,
orderDate: "2018-12-31",
isFulfilled: false,
customerId: null
}
1. customerId is set to null, which isn't allowed in JSON.

2. The date is represented as a string instead of a Date value.

3. The keys are not enclosed in double quotes, which makes the document invalid.

4. The value of isFulfilled, false, should be enclosed in double quotes.
  • 1.
  • 2.
  • 3.
  • 4.
Which of the following would successfully convert this JavaScript object to JSON? const user = { "name": "Person", "email": "person@email.com" }
  • const jsonUser = user.toJSON()
  • let jsonUser = Object.push(user, "JSON")
  • var jsonUser = Convert.toJSON(user)
  • let jsonUser = JSON.stringify(user)
💡FUN FACT 💡Douglas Crockford first specified and popularized the JSON format. The acronym originated at State Software, a company co-founded by Crockford and others in March 2001.
Historically speaking, what is one of the main goals of the JSON API specification?
1. To validate data sent from the server

2. To force clients to follow a strict standard

3. To increase the number of necessary HTTP requests

4. To eliminate the need for ad-hoc code per application to communicate with servers
  • 1.
  • 2.
  • 3.
  • 4.
Which of the following is NOT an advantage of JSON?
  • Data compressibility
  • Human readable data representation
  • Efficient representation of binary data
  • Wide availability of libraries in many languages
If an object that is being validated must have at least 3 properties provided, what size keyword should be used?
  • maxProperties
  • maxPropCount
  • minProperties
  • minimumValues
Given the JSON object below, which of the following will change the age value to 33?

const user = { "name":"Eden Powers", "age":31, "Country":"UK" };
  • user.findKey("age") = 33;
  • user["age"] = 32;
  • user.age = 33;
  • user[0].setValue("33");
What is the purpose of JSON Schema?
1. It is a JSON-based format for describing the structure of JSON data.

2. It is a mechanism for defining RESTful APIs in JSON format.

3. It is an extension to JSON which adds features such as function support.

4. It is a serialization format based on compressed JSON.
  • 1.
  • 2.
  • 3.
  • 4.
💡FUN FACT 💡JSON grew out of a need for stateless, real-time server-to-browser communication protocol without using browser plugins such as Flash or Java applets, the dominant methods used in the early 2000s
Given the schema example below, how would you indicate that the properties named "customer" and "postalCode" must be provided?

{
"type": "object",
"properties": {
"customer": { "type": "string" },
"nickname": { "type": "string" },
"address": { "type": "string" },
"postalCode": { "type": "string" }
}
}
1. "provide": { "type": "customer", "type": "postalCode" }

2. "required": [ "customer", "postalCode"]

3. "reqList": [ "customer", "postalCode"]

4. "mustHave": { "properties": [ "customer", "postalCode"] }
  • 1.
  • 2.
  • 3.
  • 4.
Which of the following is a valid way to get the cell phone number from the following JSON sample below?

const data = {"name":"Justice Doe","phone":{"cell":"555-1234","work":"555-5678"}};
  • let cell = data.phone.cell
  • const cell = JSON.getVal(data, 'cell')
  • var cell = data['phone'][0]
  • var cell = data.find('cell').first()
Given the following JSON example, how would you validate that at least one type of phone was provided: home, work or cell? {"cell":"555-1234","work":"555-5678"}
1. Provide an "allOf" array, referencing definitions for each.

2. Use the string includes function to search for 'phone' only.

3. Provide a "oneOf" array, referencing definitions for each.

4. Validate against the "series" member's list.
  • 1.
  • 2.
  • 3.
  • 4.
Which of the following is NOT a data type that is supported by JSON spec?
  • Array
  • Object
  • String
  • BigDecimal
94% of all 128 users completed this intention.
Get Started   

Or consider 82 other intentions.