6.7 JSON-Encoded Data Flashcards
Recognize components of JSON-encoded data. (33 cards)
What does the acronym JSON stand for?
JavaScript Object Notation
JSON is a lightweight, text-based format used for storing and exchanging data.
What is the primary purpose of JSON in networking?
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.
What is a JSON object?
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.
List the common use cases for JSON.
- 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.
Describe the structure of a JSON array.
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.
What is a key-value pair in JSON?
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.
True or False:
JSON data is always encoded in Unicode.
True
JSON encoding uses Unicode, allowing the representation of characters from different languages and ensuring compatibility across systems.
Fill in the blank:
JSON objects are enclosed in ______ ______.
curly braces {}
JSON objects are defined by curly braces {}, and inside them, key-value pairs are separated by commas.
Which symbol is used to denote a JSON array?
Square brackets []
JSON arrays are defined by square brackets [], containing a list of values separated by commas.
List the data types supported by JSON.
- 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.
Why is JSON preferred for data exchange in networking?
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.
What is the syntax rule for keys in a JSON object?
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.
True or False:
JSON keys are case-sensitive.
True
JSON keys are case-sensitive, so “Key” and “key” are treated as two separate keys.
Describe how JSON handles nested data.
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.
Fill in the blank
A JSON ______ is a sequence of characters in double quotes.
string
JSON strings are enclosed in double quotes and can contain Unicode characters or escape sequences like ", \, or \n.
What type of value can a JSON key have?
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.
True or False:
JSON allows comments within the data.
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.
How does JSON handle numeric data?
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.
What does the term “JSON encoding” refer to?
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.
How would you represent a boolean value in JSON?
Using true or false.
JSON represents boolean values directly as true or false without quotes.
True or False:
JSON can represent date and time values natively.
False
JSON does not have a native date/time type. Dates are typically represented as strings or numeric timestamps.
What is the null value in JSON?
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.
Why are JSON objects important in web services?
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.
How is JSON used in APIs?
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.