Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

CompTIA Exam PT0-002 Topic 4 Question 71 Discussion

Actual exam question for CompTIA's PT0-002 exam
Question #: 71
Topic #: 4
[All PT0-002 Questions]

During a REST API security assessment, a penetration tester was able to sniff JSON content containing user credentials. The JSON structure was as follows:

<

transaction_id: "1234S6", content: [ {

user_id: "mrcrowley", password: ["54321#"] b <

user_id: "ozzy",

password: ["1112228"] ) ]

Assuming that the variable json contains the parsed JSON data, which of the following Python code snippets correctly returns the password for the user ozzy?

Show Suggested Answer Hide Answer
Suggested Answer: C

To correctly return the password for the user 'ozzy' from the given JSON structure, the Python code snippet should navigate the nested structure appropriately. The 'content' array contains objects with 'user_id' and 'password' fields. The correct password for 'ozzy' can be accessed using the code json['content'][1]['password'][0], which navigates to the second object in the 'content' array (index 1) and then accesses the first element (index 0) of the 'password' array for that user.


Python JSON Handling

Python JSON Path Navigation

Contribute your Thoughts:

Lashawnda
13 days ago
I disagree, I believe the correct answer is D) json['content'][0]['password'][1]
upvoted 0 times
...
Dudley
18 days ago
I think the correct answer is C) json['content'][1]['password'][0]
upvoted 0 times
...

Save Cancel