Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- response = {
- "data": [
- {
- "type": "functionalNames",
- "id": "1",
- "attributes": {
- "id": "1",
- "title": "MDHearingAid"
- },
- "links": [
- ],
- "relationships": [
- ]
- },
- {
- "type": "functionalNames",
- "id": "2",
- "attributes": {
- "id": "2",
- "title": "Hearing aid"
- },
- "links": [
- ],
- "relationships": [
- ]
- },
- {
- "type": "functionalNames",
- "id": "47",
- "attributes": {
- "id": "47",
- "title": "Batteries"
- },
- "links": [
- ],
- "relationships": [
- ]
- },
- {
- "type": "functionalNames",
- "id": "49",
- "attributes": {
- "id": "49",
- "title": "UV Clean and Dry Box"
- },
- "links": [
- ],
- "relationships": [
- ]
- },
- {
- "type": "functionalNames",
- "id": "50",
- "attributes": {
- "id": "50",
- "title": "Hearing Aid Air Blower"
- },
- "links": [
- ],
- "relationships": [
- ]
- }
- ],
- "limit": 5,
- "offset": 0,
- "included": [
- ],
- "success": True,
- "error": {
- },
- "ver": 1,
- "service": "MS_PRODUCT"
- }
- list_Data = response['data']
- # Get data from dictionary (Old)
- list_IDs = [None]*len(list_Data)
- list_Title = [None]*len(list_Data)
- for index in range(0, len(list_Data)):
- data = list_Data[index]
- attributes = data['attributes']
- list_IDs[index] = int(attributes['id'])
- list_Title[index] = str(attributes['title'])
- # Get data from dictionary (New)
- ids = []
- titles = []
- for item in response['data']:
- ids.append(int(item['attributes']['id']))
- titles.append(str(item['attributes']['title']))
- print(ids)
- print(titles)
Add Comment
Please, Sign In to add comment