- Access exclusive content
- Connect with peers
- Share your expertise
- Find support resources
Enhanced Security Measures in Place: To ensure a safer experience, we’ve implemented additional, temporary security measures for all users.
09-29-2022 04:10 AM
Hello,
There's a list in json format named "domainUrlStatus":
{"domain1.com": {
"url1.com": {
"status": "up",
"date": "date"
},
"url2.com": {
"status": "down",
"date": "date"
}
}
"domain2.com": {
"url3.com": {
"status": "up",
"date": "date"
},
"url4.com": {
"status": "down",
"date": "date"
}
}
}
How can the values be reached(think about the "." in the urls)?
How can I add a new value like "url5.com" inside "domain1.com"?
How to modify one of the last values? (like status)
How to check if a domain exists in all the json?
Trying to avoid using own automations, only using tasks
09-29-2022 08:20 PM
Hi @Josep,
You'll need to escape the dot. Example below.
${domain\.com.url1\.com.status}
Let me know if this works for you.
09-29-2022 11:18 PM
Thanks for the reply,
so I should create a task that adds an "\" before the dot for each variable.
10-03-2022 06:39 PM - edited 10-03-2022 06:39 PM
Hi @Josep.,
Sorry I don't see any way to make changes to the keys. You might need to try different escape sequences, but I was unable to find one. Also, passing the "\" to the deleteContext automation seems to break it and creates a context context entry.
You could try passing the entire object into a python automation, but Python's JSON library might throw a schema error. Could you let me know which automation or integration is creating this context entry?
10-04-2022 12:35 AM
Yes, I'd many problems. First calling directly a variable of the list(json), like "${list}.${domain\.com.url1\.com.status}", this does not work. I need to put the Json inside the context
Second, what you said, I couldnt make changes to the keys, it was a mess, I had to convert them and then put them inside, not possible.
So finally, I made it work just doing an automation in python from zero.
Load json:
allJSON = demisto.executeCommand("getList", {"listName":"domainUrlStatus"})
data = json.loads(allJSON[0]['Contents'])
Obtain the status given a domain and an url:
status = data[domain][url]["status"]
Change the status:
data[domain][url]["status"] = newStatus
Save the change on the JSON:
demisto.executeCommand("setList",{"listName":"domainUrlStatus""listData":data})
It's a pity that something so simple can't be done with simple tasks.
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!