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!

[Puzzles] Solve, Learn, Repeat: Dynamic formatting from XML events

This challenge was first posted on Slack #puzzles channelFor a previous puzzle, I needed a set of fixed-length ...

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  &#x1f680; Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Stronger Security with Federated Search for S3, GCP SQL & Australian Threat ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...