6.7 JSON-Encoded Data Flashcards

Recognize components of JSON-encoded data. (33 cards)

1
Q

What does the acronym JSON stand for?

A

JavaScript Object Notation

JSON is a lightweight, text-based format used for storing and exchanging data.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the primary purpose of JSON in networking?

A

To exchange data between systems, especially in web services and APIs.

JSON is used to exchange data between systems, especially in APIs, configuration files, and web services, due to its lightweight and human-readable nature.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a JSON object?

A

A collection of key/value pairs.

JSON objects are enclosed in curly braces {} and consist of pairs where keys are strings and values can be different data types like numbers, booleans, arrays, or other objects.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

List the common use cases for JSON.

A
  • Web APIs
  • Configuration files
  • Data storage in NoSQL databases

Web APIs: Used for data exchange between web servers and clients.

Configuration files: Stores settings for configuring software environments.

Data storage in NoSQL databases: Stored in databases like MongoDB for scalable, flexible data models.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Describe the structure of a JSON array.

A

An ordered list enclosed in square brackets.

JSON arrays contain a list of values separated by commas and enclosed in square brackets [], with the values being any valid JSON data type.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is a key-value pair in JSON?

A

A key and its associated value.

A key is always a string, and its value can be any JSON data type, including strings, numbers, objects, arrays, booleans, or null.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

True or False:

JSON data is always encoded in Unicode.

A

True

JSON encoding uses Unicode, allowing the representation of characters from different languages and ensuring compatibility across systems.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Fill in the blank:

JSON objects are enclosed in ______ ______.

A

curly braces {}

JSON objects are defined by curly braces {}, and inside them, key-value pairs are separated by commas.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Which symbol is used to denote a JSON array?

A

Square brackets []

JSON arrays are defined by square brackets [], containing a list of values separated by commas.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

List the data types supported by JSON.

A
  • String
  • Number
  • Object
  • Array
  • Boolean
  • Null

String: A sequence of characters, enclosed in double quotes.

Number: Represents numeric values, including integers and floating-point numbers.

Object: A collection of key-value pairs enclosed in curly braces.

Array: An ordered list of values, enclosed in square brackets.

Boolean: Represents true or false values.

Null: Represents an empty or non-existent value.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Why is JSON preferred for data exchange in networking?

A

It is lightweight, human-readable, and easy to parse.

It is also widely supported across programming languages, making it efficient for data transfer in web applications and APIs.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the syntax rule for keys in a JSON object?

A

Keys must be strings in double quotes.

In JSON, keys must be strings enclosed in double quotes, e.g., “key”: “value”. Single quotes are not valid for keys.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

True or False:

JSON keys are case-sensitive.

A

True

JSON keys are case-sensitive, so “Key” and “key” are treated as two separate keys.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Describe how JSON handles nested data.

A

Objects or arrays can contain other objects or arrays.

JSON supports nesting, meaning that objects and arrays can be nested within other objects or arrays, allowing for complex data structures.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Fill in the blank

A JSON ______ is a sequence of characters in double quotes.

A

string

JSON strings are enclosed in double quotes and can contain Unicode characters or escape sequences like ", \, or \n.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What type of value can a JSON key have?

A

It must always be a string.

In JSON, keys are always strings enclosed in double quotes, and they are distinct from the values associated with them, which can be any valid JSON data type.

17
Q

True or False:

JSON allows comments within the data.

A

False

JSON does not support comments. All data within a JSON file must be part of the data structure itself, with no room for annotations.

18
Q

How does JSON handle numeric data?

A

It supports integers and floating-point numbers.

JSON handles both integers (e.g., 10) and floating-point numbers (e.g., 10.5), represented in standard decimal notation.

19
Q

What does the term “JSON encoding” refer to?

A

Converting data into JSON format.

JSON encoding involves converting data from its native format into a JSON string, making it ready for transmission or storage.

20
Q

How would you represent a boolean value in JSON?

A

Using true or false.

JSON represents boolean values directly as true or false without quotes.

21
Q

True or False:

JSON can represent date and time values natively.

A

False

JSON does not have a native date/time type. Dates are typically represented as strings or numeric timestamps.

22
Q

What is the null value in JSON?

A

It represents an empty or undefined value.

The null value in JSON signifies the absence of data or a null state, often used for missing values.

23
Q

Why are JSON objects important in web services?

A

They enable structured data exchange.

JSON objects allow data to be structured in a standardized format for easy exchange in web services, making communication between client and server more efficient.

24
Q

How is JSON used in APIs?

A

It is used for sending requests and responses.

JSON is the most commonly used format for API communication because of its simplicity and compatibility with various programming languages.

25
What does the term **"JSON parsing"** refer to?
Converting a JSON string into **usable data**. ## Footnote Parsing a JSON string involves *converting the encoded data into objects or arrays,* making it usable for processing by a program.
26
# True or False: JSON is a **binary data format**.
False ## Footnote JSON is a *text-based format*, which makes it **human-readable** and easy to debug, unlike binary formats which are more compact but less readable.
27
What is a JSON string **escape character**?
A character used to **represent** special characters. ## Footnote Escape characters such as \", \\, and \n allow *special characters* to be included in JSON strings.
28
List the **common escape characters** used in JSON strings.
* " "- Double quote * \ - Backslash * \n - Newline * \r - Carriage return ## Footnote **Double quote**: Used to escape double quotes within strings. **Backslash**: Used to escape backslashes within strings. **Newline**: Represents a new line in the string. **Carriage return**: Represents a return to the beginning of the line.
29
# True or False: JSON is **more compact** than XML for data transmission.
True ## Footnote JSON is more compact than XML because it *uses fewer tags and less markup*, making it more efficient for transmitting data.
30
# Fill in the blank: A JSON string **must be enclosed** in \_\_\_\_\_\_ \_\_\_\_\_\_.
double quotes " " ## Footnote JSON strings must be enclosed in *double quotes*, distinguishing them from other data types like numbers or booleans.
31
What is **JSON schema**?
A specification to **define the structure** of JSON data. ## Footnote JSON schema allows you to **define** the format, validation rules, and constraints for JSON data to ensure data consistency and validation.
32
What **symbol** is used to separate key-value pairs in JSON?
Colon **:** ## Footnote In JSON, each key-value pair is separated by a **colon** (key: value), which differentiates the key from its corresponding value.
33
# True or False: JSON supports **mixed data types** within a JSON object.
True ## Footnote JSON objects can **store** mixed data types in their *key-value pairs*, allowing strings, numbers, arrays, objects, and other valid JSON types as values.