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:

Kate
2 months ago
Wait, is this a real exam question or did someone just make it up to see how many hackers they can lure in? I'm starting to have trust issues here.
upvoted 0 times
...
Caitlin
2 months ago
Ah, the age-old 'which list index do I use?' conundrum. I'm gonna have to go with C on this one, it just makes the most sense to me.
upvoted 0 times
...
Victor
2 months ago
Hold up, is this some kind of trick question? I feel like the answer should be obvious, but I don't want to get caught out. I'm gonna go with C just to be safe.
upvoted 0 times
...
Wilson
2 months ago
Hmm, I'm not sure about this one. Option C looks good, but I'm also kind of tempted by option D. Guess I'll have to double-check the JSON structure.
upvoted 0 times
...
Angelyn
2 months ago
Wow, this is a tricky one! I'm pretty sure the password for ozzy is in the second user object, so I'd go with option C.
upvoted 0 times
Luis
1 months ago
I agree, option C is the one to go with.
upvoted 0 times
...
Georgiana
1 months ago
Option C seems to be the right choice.
upvoted 0 times
...
Deeanna
1 months ago
Actually, I believe the correct answer is option C as well. It should be json['content'][1]['password'][0].
upvoted 0 times
...
Billy
2 months ago
No, I think it's option D that correctly returns the password for the user ozzy.
upvoted 0 times
...
Carmelina
2 months ago
I would choose option C as well.
upvoted 0 times
...
Gerald
2 months ago
I agree, option C looks like the right choice to get the password for ozzy.
upvoted 0 times
...
Paris
2 months ago
I think option C is correct too.
upvoted 0 times
...
Judy
2 months ago
I think the password for ozzy is in the second user object, so option C seems correct.
upvoted 0 times
...
...
Lashawnda
3 months ago
I disagree, I believe the correct answer is D) json['content'][0]['password'][1]
upvoted 0 times
...
Dudley
3 months ago
I think the correct answer is C) json['content'][1]['password'][0]
upvoted 0 times
...

Save Cancel