350-401 Question 316
Single answerYou are tasked with creating a JSON configuration file for a network automation tool. The file needs to define the following properties:
- A 'host' field that specifies the IP address '192.168.1.1'.
- A 'port' field set to the integer value 22.
- A 'protocols' field that lists the supported protocols: 'SSH' and 'HTTPS'.
- A 'credentials' object that contains a 'username' field set to 'admin' and a 'password' field set to 'cisco123'.
Which of the following JSON files is valid and meets the requirements?
- A
{ "host": "192.168.1.1", "port": 22, "protocols": ["SSH", "HTTPS"], "credentials": { "username": "admin", "password": "cisco123" } }
- B
{ "host": 192.168.1.1, "port": "22", "protocols": "SSH, HTTPS", "credentials": { "username": "admin", "password": "cisco123" } }
- C
{ "host": "192.168.1.1", "port": 22, "protocols": ["SSH", "HTTPS"], "credentials": ["username": "admin", "password": "cisco123"] }
- D
{ "host": "192.168.1.1", "port": 22, "protocols": ["SSH", "HTTPS"], "credentials": { "username": "admin", "password": "cisco123" }, }
Show answer and explanation
Correct answer: A
Explanation
JSON files must follow strict syntax rules. Keys and string values must be enclosed in double quotes, lists should use square brackets, and objects should use curly braces. The trailing comma in option 4 is invalid, and other options fail to meet the required structure or formatting.
- A. Correct.
This is the correct JSON structure. The 'host' is a string, 'port' is an integer, 'protocols' is a list of strings, and 'credentials' is a nested object with correct key-value pairs.
- B. Incorrect.
This JSON is invalid because the 'host' field is not quoted as a string, the 'port' is incorrectly quoted as a string, and the 'protocols' field is improperly formatted as a single string instead of a list.
- C. Incorrect.
This JSON is invalid because the 'credentials' field is incorrectly formatted as a list instead of an object with key-value pairs.
- D. Incorrect.
This JSON is invalid because there is a trailing comma after the 'credentials' object, which violates JSON syntax rules.