Closed beezly closed 12 years ago
This looks like it contains the same changes as PR #3?
Awesome. I actually ran into a similar issue in our JS SDK, but I was looking at the XML output rather than JSON.
One question: would it be possible to detect the REST API returning an empty string and replacing it with "[]"
? In JavaScript, for example, I might do something like:
response = response || "[]"
Just wondering if something similar is possible for Ruby (you'll have to excuse my ignorance) :)
@ampledata I don't think so - this one contains a code change
@itay it's straight forward to do that, although I think the "empty" response actually contains "\n". If that would be better I'll create a different pull request.
@ampledata my fault. I created the pull request badly for #3. This one is just fixing the "empty result" problem.
@beezly you know Ruby better than I do, so you can be the judge of what is more idiomatic. :)
@itay This one can be closed. It got merged as part of #3 because I created the pull request badly :(
Having said that, I think this is a better solution than cleaning up the \n anyway.
Splunk::Jobs.create_oneshot currently throws a JSON::ParserError if there are no results returned by the REST API.
This commit catches a JSON::ParserError and returns a SearchResult of an empty array for consistency.