with open('data.txt', 'r') as file:
dat2 = file.read()
post2 = {
"id": 5,
"method": "set",
"params": [
{
"data": [
dat2
],
"url": "/config/url"
},
]
"session": sessionkey,
"verbose": 1
}
Data from the file I am trying to read looks as so...{"name": "IPS10-Host1","type": "ipmask","subnet": ["","255.255.255.255"],"dynamic_mapping": null}, {"name": "IPS10-Host2","type": "ipmask","subnet": ["","255.255.255.255"],"dynamic_mapping": null},
I am trying to read this data and insert into a variable to put it into post2
for a request. What I have tried so far includes: reading the file and replacing null
with None
so python can read it as well as stripping all of the whitespace. I have tried using json.loads()
and json.dumps()
, but nothing seems to work. After the data is placed into dat2
, it gets inserted into post2
as '{data}'
instead of {data}
. I have been stuck on this part of my code for the longest time now and would appreciate and ideas.