{ "ahsapd.macfilter": { "macFilterEnable": , "macFilterPolicy": , "macFilterEntries":" } }转换为blobmsg格式数据,并重新解析
时间: 2023-11-08 13:05:04 浏览: 26
blobmsg格式数据:
```
{
"ahsapd.macfilter": {
"macFilterEnable": true,
"macFilterPolicy": "allow",
"macFilterEntries": ["00:01:02:03:04:05", "11:22:33:44:55:66"]
}
}
```
重新解析代码:
```python
import json
data = {
"ahsapd.macfilter": {
"macFilterEnable": True,
"macFilterPolicy": "allow",
"macFilterEntries": ["00:01:02:03:04:05", "11:22:33:44:55:66"]
}
}
# 将数据转换为json格式字符串
json_str = json.dumps(data)
# 将json格式字符串转换为python对象
new_data = json.loads(json_str)
# 输出解析后的数据
print(new_data)
```
输出结果:
```
{'ahsapd.macfilter': {'macFilterEnable': True, 'macFilterPolicy': 'allow', 'macFilterEntries': ['00:01:02:03:04:05', '11:22:33:44:55:66']}}
```
阅读全文