- Access exclusive content
- Connect with peers
- Share your expertise
- Find support resources
10-05-2022 01:55 AM
Hello,
I've some urls to introduce in a JSON list the command used are this one to encode:
#encode to ASCII
url.encode(encoding='ascii',errors="ignore").decode()
In the context the variable is perfect, however inside the JSON list it's not. Even if I call variables from inside the JSON list to outside is perfect too.
It's only inside the JSON list where differents characters appear.
10-05-2022 11:49 PM
Sorry for not giving more information, I have to be carefull with it. Here it's a smaller part of the program, where a JSON list is loaded, and parameters are changed, then JSON List is updated. The question is about why is not encoded in ASCII even if I force to do it inside the JSON List.
def main(domain, url):
domain = domain.encode(encoding='ascii',errors="ignore").decode()
url = url.encode(encoding='ascii',errors="ignore").decode()
allJSON = demisto.executeCommand("getList", {"listName":"JSONList"})
data = json.loads(allJSON[0]['Contents'])
newdata = {domain:{"domain": domain,"url":url}}
if type(data) is list:
data.append(newdata)
else:
data.update(newdata)
demisto.executeCommand("setList",{"listName":"JSONList","listData":data})
Click Accept as Solution to acknowledge that the answer to your question has been provided.
The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!
These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the LIVEcommunity as a whole!
The LIVEcommunity thanks you for your participation!