JSON MCQs – Performance and Security

11.) Why should you limit the depth of nested JSON objects?

A) To improve readability
B) To reduce data size
C) To remove duplicate keys
D) To prevent DoS attacks caused by deep recursion

Answer: Option D

Explanation: Excessive nesting can lead to recursive parsing issues, causing resource exhaustion.

12.) What is the effect of caching JSON responses?

A) Reduces server processing time for repeated requests
B) Increases JSON size
C) Prevents JSON injection attacks
D) Converts JSON to binary format

Answer: Option A

Explanation: Caching JSON responses reduces server processing for repeated requests, improving performance.

13.) How can you validate JSON in a secure and efficient way?

A) Use custom regular expressions
B) Use a JSON Schema validator
C) Manually check the JSON
D) Ignore validation for trusted sources

Answer: Option B

Explanation: JSON Schema validators efficiently and securely validate JSON data against defined schemas.

14.) Which type of JSON structure is most efficient for transmitting data?

A) Deeply nested objects
B) Objects with arrays
C) Flat, simple key-value pairs
D) JSON with comments

Answer: Option C

Explanation: Flat, simple structures are easier to parse and transmit, improving efficiency.

15.) What is the primary advantage of using binary JSON formats like BSON?

A) Smaller size and faster parsing
B) Enhanced readability
C) Compatibility with XML
D) Automatic validation

Answer: Option A

Explanation: Binary JSON formats like BSON are smaller and faster to parse, making them efficient for large datasets.

16.) How does HTTPS improve the security of JSON data transmission?

A) It makes JSON larger
B) It encrypts JSON data in transit
C) It validates JSON schemas
D) It beautifies JSON responses

Answer: Option B

Explanation: HTTPS encrypts JSON data during transmission, preventing eavesdropping and tampering.

17.) What is the potential issue with using eval() to parse JSON strings in JavaScript?

A) Slower parsing
B) Vulnerability to code injection attacks
C) Increased memory usage
D) It cannot parse valid JSON strings

Answer: Option B

Explanation: Using eval() to parse JSON exposes the application to code injection attacks. Always use JSON.parse() for secure parsing.

18.) How can JSON responses be protected from being cached by unauthorized users?

A) Use the Cache-Control header with no-store
B) Minify the JSON data
C) Use large nested objects
D) Convert JSON to XML

Answer: Option A

Explanation: The Cache-Control header with no-store prevents sensitive JSON data from being stored in caches.

19.) What is a safe alternative to eval() for parsing JSON in JavaScript?

A) JSON.stringify()
B) JSON.parse()
C) JSON.minify()
D) JSON.debug()

Answer: Option B

Explanation: JSON.parse() is the recommended and secure way to parse JSON strings in JavaScript.

20.) How does JSON web encryption (JWE) enhance JSON security?

A) It adds authentication to JSON
B) It compresses JSON data
C) It encrypts JSON payloads for secure transmission
D) It converts JSON to binary format

Answer: Option C

Explanation: JSON Web Encryption (JWE) ensures that the payload is encrypted, protecting it from unauthorized access during transmission.

Leave a Reply

Your email address will not be published. Required fields are marked *