Docsity

Exam Contributor Open Data Formats JSON Practice Exam, Exams of Technology

Toggle sidebar
bg1
Exam Contributor Open Data Formats
JSON Practice Exam
**Question 1. Which of the following best describes JSON’s primary purpose?**
A) To define styling rules for web pages
B) To store binary image data efficiently
C) To provide a language‑independent, text‑based data interchange format
D) To execute server‑side scripts
Answer: C
Explanation: JSON (JavaScript Object Notation) is designed as a lightweight,
language‑independent format for transmitting structured data between a server and a client.
**Question 2. Compared with CSV, JSON is more suitable for representing:**
A) Simple tabular data with fixed columns
B) Hierarchical or nested data structures
C) Large binary files
D) Plain text documents
Answer: B
Explanation: CSV is flat and row‑based, while JSON can nest objects and arrays, making it ideal
for hierarchical data.
**Question 3. Which of the following is NOT a valid JSON data type?**
A) String
B) Date
C) Boolean
D) Null
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b

Partial preview of the text

Download Exam Contributor Open Data Formats JSON Practice Exam and more Exams Technology in PDF only on Docsity!

JSON Practice Exam

Question 1. Which of the following best describes JSON’s primary purpose? A) To define styling rules for web pages B) To store binary image data efficiently C) To provide a language‑independent, text‑based data interchange format D) To execute server‑side scripts Answer: C Explanation: JSON (JavaScript Object Notation) is designed as a lightweight, language‑independent format for transmitting structured data between a server and a client. Question 2. Compared with CSV, JSON is more suitable for representing: A) Simple tabular data with fixed columns B) Hierarchical or nested data structures C) Large binary files D) Plain text documents Answer: B Explanation: CSV is flat and row‑based, while JSON can nest objects and arrays, making it ideal for hierarchical data. Question 3. Which of the following is NOT a valid JSON data type? A) String B) Date C) Boolean D) Null

JSON Practice Exam

Answer: B Explanation: JSON has no native Date type; dates are usually represented as ISO‑8601 strings. Question 4. In JSON syntax, which characters must surround object keys? A) Single quotes ' B) Backticks ` C) Double quotes " D) No quotes are required Answer: C Explanation: JSON requires object keys to be double‑quoted strings. Question 5. Which of the following JSON fragments contains a syntax error? A) {"name":"Alice","age":30} B) {"name":"Bob", "age":25,} C) {"items":["apple","banana"]} D) {"valid":true} Answer: B Explanation: The trailing comma after the last key/value pair is illegal in JSON. Question 6. What is the effect of minifying a JSON document? A) Adding extra whitespace for readability B) Removing all unnecessary whitespace and line breaks

JSON Practice Exam

Question 9. How would you represent a binary file (e.g., an image) in JSON? A) Directly embed the binary bytes B) Use a Base64‑encoded string C) Write the file path as a string D) JSON cannot represent binary data Answer: B Explanation: Binary data is commonly encoded as a Base64 string to fit within JSON’s text format. Question 10. Which of the following is the correct way to encode a newline character inside a JSON string? A) "\n" B) "\\n" C) "\r" D) "\\r" Answer: A Explanation: The escape sequence \n inserts a newline character; \\n would produce a literal backslash followed by “n”. Question 11. Which numeric representation is NOT allowed in JSON? A) 42 B) 3.14 C) 1e-5 D) 0xFF

JSON Practice Exam

Answer: D Explanation: JSON numbers must be in decimal notation; hexadecimal (0xFF) is invalid. Question 12. Which statement about JSON booleans is correct? A) They are case‑insensitive (TRUE, true, True) B) They must be written as true or false in lowercase C) They can be represented as "true" (a string) D) JSON does not support booleans Answer: B Explanation: JSON boolean literals are strictly true or false in lowercase. Question 13. How is a null value represented in JSON? A) "null" (a string) B) null (without quotes) C) NULL (uppercase) D) It cannot be represented Answer: B Explanation: The literal null (without quotes) denotes an empty or missing value in JSON. Question 14. Which of the following is a valid way to represent a date in JSON? A) "2023- 08 - 15T13:45:00Z" B) new Date("2023- 08 - 15")

JSON Practice Exam

Question 17. What does the JSONPath expression $..author select? A) The root object only B) All author properties at any depth C) The immediate child named author of the root D) Nothing; the syntax is invalid Answer: B Explanation: The .. recursive descent operator retrieves all author members regardless of nesting. Question 18. Which JSONPath filter selects items where the price is greater than 20? A) $.items[?(@.price > 20)] B) $.items[price > 20] C) $..[price > 20] D) $.items[?(@price > 20)] Answer: A Explanation: The filter syntax ?(@.price > 20) evaluates each element’s price property. Question 19. In JSON Schema, the keyword type can be used to specify: A) The programming language used to generate the JSON B) The allowed data type(s) for a value C) The version of the JSON specification D) The size of the JSON document in bytes

JSON Practice Exam

Answer: B Explanation: type restricts a property to one or more JSON data types (e.g., "string", "number"). Question 20. Which JSON Schema keyword ensures a numeric value is at least 0 and at most 100? A) range: [0,100] B) minimum: 0, maximum: 100 C) min: 0, max: 100 D) bounds: { "min":0, "max":100 } Answer: B Explanation: minimum and maximum define inclusive lower and upper bounds for numeric instances. Question 21. How would you enforce that a string property matches an email pattern in JSON Schema? A) "pattern": "^[\\w.%+-]+@[\\w.-]+\\.[A-Za-z]{2,}$" B) "format": "email" C) Both A and B are valid options D) "type": "email" Answer: C Explanation: "format":"email" is a built‑in format; a regular expression via "pattern" also works.

JSON Practice Exam

Answer: C Explanation: allOf requires the instance to match every subschema in the array. Question 25. What does the JSON Schema keyword uniqueItems: true enforce? A) All object keys must be unique across the document B) No duplicate values in an array C) No duplicate schemas in $defs D) All property names must be unique within an object Answer: B Explanation: uniqueItems ensures that each array element is distinct. Question 26. Which of the following JSON strings is correctly escaped? A) "He said, \"Hello!\"" B) "Path: C:\folder\file.txt" C) "Line1\nLine2" D) Both A and C Answer: D Explanation: Both examples use proper escape sequences for quotes and newline; B lacks escaping of the backslashes. Question 27. Which of the following is a valid JSON representation of a GeoJSON Point? A) {"type":"Point","coordinates":[102.0,0.5]}

JSON Practice Exam

B) {"type":"Point","coordinates":{"lon":102.0,"lat":0.5}} C) {"type":"Feature","geometry":"Point","coordinates":[102.0,0.5]} D) {"type":"Point","coords":[102.0,0.5]} Answer: A Explanation: GeoJSON specifies a type of "Point" and a numeric coordinate array [longitude, latitude]. Question 28. In JSON‑LD, the @context field is used to: A) Define the character encoding of the document B) Map compact terms to IRIs for linked data C) List all available APIs D) Encrypt the JSON payload Answer: B Explanation: @context provides term definitions that expand compact keys into full IRIs. Question 29. Which HTTP header is most important to indicate that a JSON response uses UTF‑8 encoding? A) Content-Type: application/json; charset=utf-8 B) Accept-Encoding: gzip C) Cache-Control: no-cache D) Authorization: Bearer token Answer: A

JSON Practice Exam

Question 32. Which binary format is a superset of JSON and adds support for additional data types like ObjectId and binary? A) BSON B) MessagePack C) CBOR D) Avro Answer: A Explanation: BSON (Binary JSON) extends JSON with extra types and is used by MongoDB. Question 33. In JSON‑API, how are related resources typically represented? A) As nested objects inside the primary resource B) Using a relationships object with links and data members C) By embedding raw URLs in string fields D) JSON‑API does not support relationships Answer: B Explanation: JSON‑API defines a relationships member that contains linkage information and optional links. Question 34. Which JSONPath expression selects the first element of an array named items? A) $.items[0] B) $.items[1] C) $.items[first()] D) $.items[:1]

JSON Practice Exam

Answer: A Explanation: Array indices are zero‑based; [0] returns the first element. Question 35. Which of the following statements about whitespace in JSON is true? A) Whitespace inside string values is significant and must be escaped B) Whitespace outside strings is ignored and can be used freely C) JSON parsers reject any whitespace characters other than spaces D) Whitespace determines the order of object properties Answer: B Explanation: JSON allows spaces, tabs, line feeds, and carriage returns between tokens; they do not affect data. Question 36. Which regular expression pattern in JSON Schema would allow only uppercase alphabetic characters of length exactly 3? A) "pattern": "^[A-Z]{3}$" B) "pattern": "^[A-Z]{1,3}$" C) "pattern": "^[A-Z]+$" D) "pattern": "^.{3}$" Answer: A Explanation: ^[A-Z]{3}$ matches exactly three uppercase letters. Question 37. In JSON Schema, the keyword enum is used to:

JSON Practice Exam

Answer: A Explanation: Draft‑ 07 ’s meta‑schema URI ends with draft-07. Question 40. What does the JSONPath expression $..* return? A) All root‑level properties only B) Every value in the document, recursively C) All object keys without their values D) Nothing; the syntax is invalid Answer: B Explanation: The wildcard * with recursive descent .. selects every element/value in the JSON tree. Question 41. Which of the following is the correct way to serialize a JavaScript object obj to a JSON string? A) JSON.stringify(obj) B) JSON.parse(obj) C) obj.toJSON() D) obj.serialize() Answer: A Explanation: JSON.stringify converts a JavaScript value into a JSON‑formatted string. Question 42. Which method parses a JSON string into a native JavaScript object? A) JSON.encode()

JSON Practice Exam

B) JSON.parse() C) JSON.deserialize() D) Object.fromJSON() Answer: B Explanation: JSON.parse reads a JSON string and returns the corresponding JavaScript value. Question 43. When streaming a large JSON array from a server, which technique helps reduce memory usage? A) Sending the entire array as a single payload B) Using newline‑delimited JSON (NDJSON) where each line is a separate JSON object C) Encoding the array in Base D) Compressing the array with ZIP before sending Answer: B Explanation: NDJSON allows the client to process each line incrementally, avoiding the need to hold the whole array in memory. Question 44. Which of the following best describes the purpose of $defs in a JSON Schema? A) To define reusable subschemas within the same document B) To declare global variables for the schema C) To set default values for properties D) To list required properties Answer: A

JSON Practice Exam

C) "price": {"type":"integer","minimum":1} D) "price": {"type":"string","pattern":"^[0-9]+(\\.[0-9]{2})?$"} Answer: A Explanation: exclusiveMinimum:true together with minimum:0 forces the value to be >0. Question 48. Which JSONPath operator is used for deep scanning of all descendant nodes? A) .. B) * C) . D) ?() Answer: A Explanation: The double‑dot .. recursively searches all levels beneath the current node. Question 49. Which of the following statements is true about JSON and XML? A) JSON supports comments natively, XML does not B) XML can represent mixed content (elements with both text and child elements) while JSON cannot C) JSON requires a schema while XML does not D) XML is always more compact than JSON Answer: B Explanation: XML allows mixed content; JSON’s value types are limited to objects, arrays, strings, numbers, booleans, and null.

JSON Practice Exam

Question 50. When using JSON.stringify with a replacer array, what effect does it have? A) It filters out properties not listed in the array, preserving order B) It changes numeric values to strings C) It encrypts the output D) It adds indentation to the output Answer: A Explanation: The replacer array acts as a whitelist, including only the specified keys in the resulting JSON string. Question 51. Which of the following is a valid way to reference an external schema in JSON Schema? A) "$ref": "http://example.com/schemas/address.json" B) "$include": "address.schema" C) "ref": "#/definitions/address" D) "schema": "address" Answer: A Explanation: $ref with a URI points to an external schema document. Question 52. In JSON‑API, what is the purpose of the meta member? A) To provide non‑standard, non‑resource‑specific information about the response B) To list all related resources C) To define pagination links