350-901 practice question 23 of 35
{'lat': 37.4180951010362, 'lng': -122.098531723022, 'address': '', 'serial': 'Q2HP-F5K5-F98Q', 'mac': '88:15:44:ea:f5:bf', 'lanIp': '10.10.10.15'…
Full set: 430 questionsDomain Software Development and Design
The response.text attribute from the Python requests library contains the raw response body as a string. The exhibit shows this string is in JSON format. To work with this data as a structured object in Python, it must be deserialized or parsed. The requests library provides a built-in method, .json(), which parses the JSON string into a Python dictionary. After parsing, the values for latitude and longitude can be accessed using their corresponding keys, 'lat' and 'lng', with standard Python dictionary syntax: dictionary['key'].
A. response.text is a string. Attempting to access it with dictionary-style keys like ['lat'] will result in a TypeError because strings are not subscriptable with string keys.
C. The .json() method in this case returns a single dictionary, not a list (JSON array). Accessing it with numerical indices like [0] will cause a KeyError.
D. Accessing response.text with numerical indices like [0] would retrieve the first character of the raw string ({), not the value associated with a key.
1. Official Vendor Documentation (Cisco Meraki): The Meraki Dashboard API documentation for the "Get device" endpoint (GET /devices/{serial}) shows that the response body is a JSON object containing keys such as lat and lng. This confirms the data structure shown in the exhibit.
Source: Meraki Developer Hub
Dashboard API V1
"Get device". (developer.cisco.com/meraki/api-v1/#!get-device)
2. Official Vendor Documentation (Python requests library): The official documentation for the requests library explicitly describes the use of the .json() method for handling JSON responses. It states
"There’s also a built-in JSON decoder
in case you’re dealing with JSON data... r.json()".
Source: requests Documentation
Version 2.31.0
"JSON Response Content". (requests.readthedocs.io/en/latest/user/quickstart/#json-response-content)
3. University Courseware (University of Michigan): Course materials for "Python for Everybody" explain how to parse JSON data retrieved from a web service. The materials demonstrate that after fetching data
it must be loaded from a string (if not using a library helper like .json()) into a dictionary to be accessed by key.
University of Michigan
"Python for Everybody
" Course 4: Using Python to Access Web Data
Chapter 13: Web Services and XML. (www.py4e.com/html3/13-web)
Keep practicing
Take the free 350-901 practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other 350-901 practice questions
- Question 2An application has initiated an OAuth authorization code grant flow to get access to an A…
- Question 3A developer is working on an enhancement for an application feature and has made changes …
- Question 4An automated solution is needed to configure VMs in numerous cloud provider environments …
- Question 9A web application is being developed to provide online sales to a retailer. The customers…
- Question 11While developing an application following the 12-factor app methodology, which approach s…
- Question 16A user is receiving a 429 Too Many Requests error. Which scheme is the server employing t…
