<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: From InputStream to JsonArray in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/From-InputStream-to-JsonArray/m-p/68625#M17222</link>
    <description>&lt;P&gt;Also learn &lt;A href="https://www.java8net.com/2020/03/serialize-arraylist-in-java.html"&gt;how to serialize arraylist in java&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 27 Mar 2020 14:52:43 GMT</pubDate>
    <dc:creator>aryank4564</dc:creator>
    <dc:date>2020-03-27T14:52:43Z</dc:date>
    <item>
      <title>From InputStream to JsonArray</title>
      <link>https://community.splunk.com/t5/Splunk-Search/From-InputStream-to-JsonArray/m-p/68622#M17219</link>
      <description>&lt;P&gt;I would like to know how to get a Json array from an InputStream Object.&lt;/P&gt;

&lt;P&gt;Actually I am trying to store some splunk raw parameters like host, sourcetype, and source in a string list and then passed into JobResultArgs. Then passed into InputStream as a Job object. Now i want that to be passed to a Json Array to get the result size and pass throught the array and get the host and source objects.&lt;/P&gt;

&lt;P&gt;JobResultsArgs jobRes = new JobResultsArgs();&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;      List&amp;lt;String&amp;gt; fields = new ArrayList&amp;lt;String&amp;gt;();

    fields.add("_raw");
    fields.add("host");
    fields.add("sourcetype");
    fields.add("source");

    jobRes.setFieldList((String[])fields.toArray());
    jobRes.setCount(2500);


    InputStream inpStream = job.getResults(jobRes);  
    ResultsReaderJson Jsa = new ResultsReaderJson(inpStream);

      //      System.out.println("result size: " + Jsa.size());
     //  for(int i = 0; i &amp;lt; Jsa.size(); i++) {


   //   JsonElement hostElement = Jsa.get(i).getAsJsonObject().get("host");
  //    JsonElement source = Jsa.get(i).getAsJsonObject().get("source");
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The  commented lines are not compatable with the code but i want to implement this kind of code. Is there a way i can get a Json Array from the InputStream&lt;/P&gt;</description>
      <pubDate>Wed, 20 Mar 2013 19:15:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/From-InputStream-to-JsonArray/m-p/68622#M17219</guid>
      <dc:creator>kalyani1184</dc:creator>
      <dc:date>2013-03-20T19:15:00Z</dc:date>
    </item>
    <item>
      <title>Re: From InputStream to JsonArray</title>
      <link>https://community.splunk.com/t5/Splunk-Search/From-InputStream-to-JsonArray/m-p/68623#M17220</link>
      <description>&lt;P&gt;For the commented part you may be looking for ResultsReader.getNextEvent(): &lt;A href="http://docs.splunk.com/DocumentationStatic/JavaSDK/1.0/index.html?com/splunk/ResultsReader.html"&gt;http://docs.splunk.com/DocumentationStatic/JavaSDK/1.0/index.html?com/splunk/ResultsReader.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Mar 2013 19:48:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/From-InputStream-to-JsonArray/m-p/68623#M17220</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2013-03-20T19:48:53Z</dc:date>
    </item>
    <item>
      <title>Re: From InputStream to JsonArray</title>
      <link>https://community.splunk.com/t5/Splunk-Search/From-InputStream-to-JsonArray/m-p/68624#M17221</link>
      <description>&lt;P&gt;Thank you for the response. I looked previously but that was not i wanted. I wanted to get the size of it and the host name source name which i could not find from that.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Mar 2013 21:35:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/From-InputStream-to-JsonArray/m-p/68624#M17221</guid>
      <dc:creator>kalyani1184</dc:creator>
      <dc:date>2013-03-20T21:35:57Z</dc:date>
    </item>
    <item>
      <title>Re: From InputStream to JsonArray</title>
      <link>https://community.splunk.com/t5/Splunk-Search/From-InputStream-to-JsonArray/m-p/68625#M17222</link>
      <description>&lt;P&gt;Also learn &lt;A href="https://www.java8net.com/2020/03/serialize-arraylist-in-java.html"&gt;how to serialize arraylist in java&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Mar 2020 14:52:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/From-InputStream-to-JsonArray/m-p/68625#M17222</guid>
      <dc:creator>aryank4564</dc:creator>
      <dc:date>2020-03-27T14:52:43Z</dc:date>
    </item>
  </channel>
</rss>

