0

i want to extract Mac_Address from this json in python. anyone can help ?

{"list":
    [{
       "Group_Devices_id":3,
       "User_Id":19,
       "Mac_Address":" fe80::f17a:4a64:7192:ed68%2 ",
       "Master_Device":"T"
    }],
    "success":true}
Irum Zahra Awan
  • 276
  • 1
  • 5
  • 16

2 Answers2

0
- Import json
- data = json.loads('{"list": [{ "Group_Devices_id":3, "User_Id":19,
   "Mac_Address":" fe80::f17a:4a64:7192:ed68%2 ", "Master_Device":"T"
   }], "success":true}')
- data['list'][0]['Mac_Address']

Desc : Import json libraray, then load your data. then access any elements.
logsv
  • 544
  • 6
  • 17
0
import json
data = json.loads('{"list": [{ "Group_Devices_id":3, "User_Id":19,
       "Mac_Address":" fe80::f17a:4a64:7192:ed68%2 ", "Master_Device":"T"
       }], "success":true}'

for item in data["list"]:
   print item["Mac_Address"]

1) Load data

2) Assume you need to get Mac_Address from lots of data of list, then use "for...in.." to process

maomifadacai
  • 357
  • 2
  • 4
  • 17
  • Please include some explanation around your answer as to why it solves the OP's original question. This may help - [answer] – Tom Feb 06 '17 at 11:50