- Products
- Learn
- Local User Groups
- Partners
- More
MVP 2026: Submissions
Are Now Open!
What's New in R82.10?
Watch NowOverlap in Security Validation
Help us to understand your needs better
CheckMates Go:
Maestro Madness
I have a little python script that works great and i have this piece that runs an api command to get members from a group
client.api_call("show-group", {"name": "TestGrp"})
But i am trying to pass it to jq to filter out only the data I need which is just name and type. If i run it in the cli using mgmt_cli I can pass to jq no problem, but how do I do it in python using this type of api call?
Pretty sure there ways to parse JSON with native Python modules.
Think there is also a JQ module for Python.
Thanks for your response.
I just tried using the jq library but everytime I try to load it into json it keeps giving me the error that it can't load an api response, is there a way to convert it to a json object so it can load successfully.
Our API only returns results in JSON.
I suspect it has to do with how you’re calling it in Python, but don’t know for certain.
Recommend looking at some working examples in the community.
Hi, If you can share the rest of the script I'd happily take a look (make sure you've edited out any sensitive data).
Generally, you would store the output of your API call into a variable:
my_results = client.api_call("show-group", {"name": "TestGrp"})
depending on what's returned, you might either have a string which contains JSON, or a Python object. If you're using an IDE like Visual Studio Code or PyCharm, you should be able to debug the script and add a breakpoint after this line to see the class of my_results. If it's a string, you can use "my_ object = json.loads(my_results)", if it's an object you can start using it however you like (again, the debug panel will help with what methods to use to interrogate the data).
@StuartGreenbasically already explained it. However if you want to understand it in detail I can recommend you to check out https://www.w3schools.com/python/python_json.asp.
Basically, with "json.loads()" you can "import" json data into python to then query it like a list or dictionary.
Afterwards, if you want the json format back, you can use "json.dumps()" to re-create a json out of the filtered data - if required.
To add to those great answers, I found IDLE of Python is great in loading values and checking the types (type()) of those variables so that you know what to expect. In addition to that, if you are using VS Code (if not I highly recommend it, it's free as well and runs on Windows/Linux/macOS), you can load great plugins for Python that on the fly will give you docs of the libraries plus the return functions and methods types (dict, list, object, etc.). It all depends on your setup of the IDE.
As you start manipulating data of JSON datasets, you will need to loop through the variables. Nested loops will be commonly expected data, as that's what you do with JQ as well. Take a look at:
hxxps://www.codespeedy.com/how-to-loop-through-json-with-subkeys-in-python/
I personally like to work with Python Comprehensions for if and for functions. Check out:
hxxps://realpython.com/list-comprehension-python/
Have fun!
Leaderboard
Epsum factorial non deposit quid pro quo hic escorol.
| User | Count |
|---|---|
| 4 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |
Tue 16 Dec 2025 @ 05:00 PM (CET)
Under the Hood: CloudGuard Network Security for Oracle Cloud - Config and Autoscaling!Thu 18 Dec 2025 @ 10:00 AM (CET)
Cloud Architect Series - Building a Hybrid Mesh Security Strategy across cloudsTue 16 Dec 2025 @ 05:00 PM (CET)
Under the Hood: CloudGuard Network Security for Oracle Cloud - Config and Autoscaling!Thu 18 Dec 2025 @ 10:00 AM (CET)
Cloud Architect Series - Building a Hybrid Mesh Security Strategy across cloudsAbout CheckMates
Learn Check Point
Advanced Learning
YOU DESERVE THE BEST SECURITY