Problem encoding/decoding introducing in a JSON list data

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Please sign in to see details of an important advisory in our Customer Advisories area.

Problem encoding/decoding introducing in a JSON list data

L4 Transporter

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.

 

2 REPLIES 2

L4 Transporter

Hi @Josep,

 

Need more information on this is issue. Maybe share the code you're running. 

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})

 

 

  • 1097 Views
  • 2 replies
  • 0 Likes
Like what you see?

Show your appreciation!

Click Like if a post is helpful to you or if you just want to show your support.

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!