Splunk Dev

JSONResultsReader

MK3
Explorer

Hello,

I have this -

results = service.jobs.oneshot(searchquery_oneshot, **kwargs_oneshot)
reader = results.JSONResultsReader(oneshotsearch_results)
 
dict = json.loads(oneshotsearch_results)  # to get dict to send data outside splunk selectively
 
Error:
TypeError: the JSON object must be str, bytes or bytearray, not ResponseReader
 
How do I fix this?
 
Thanks
 
 
0 Karma
1 Solution

PaulPanther
Motivator

Please try:

    oneshotsearch_results = service.jobs.oneshot(searchquery_oneshot, **kwargs_oneshot)
    reader = results.JSONResultsReader(oneshotsearch_results)

 

View solution in original post

0 Karma

PaulPanther
Motivator

Please try:

    oneshotsearch_results = service.jobs.oneshot(searchquery_oneshot, **kwargs_oneshot)
    reader = results.JSONResultsReader(oneshotsearch_results)

 

0 Karma

MK3
Explorer

hi @PaulPanther, after doing so as you suggested, I am trying to read the JSONResultsReader object like this-

for item in reader:

    if(isinstance(item, dict)):

        for key in item:
            if(key == '<...>'):
                A = str(item[key])
                print('A is :',A)
 
The above code was working till yesterday. Now it does not enter the 1st for loop anymore.
0 Karma
Get Updates on the Splunk Community!

Unlock Database Monitoring with Splunk Observability Cloud

In today’s fast-paced digital landscape, even minor database slowdowns can disrupt user experiences and stall ...

Print, Leak, Repeat: UEBA Insider Threats You Can't Ignore

Are you ready to uncover the threats hiding in plain sight? Join us for "Print, Leak, Repeat: UEBA Insider ...

Splunk MCP & Agentic AI: Machine Data Without Limits

  Discover how the Splunk Model Context Protocol (MCP) Server can revolutionize the way your organization ...