<?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 How to extract Json array ? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-Json-array/m-p/679825#M232384</link>
    <description>&lt;P&gt;Thanks in Advance.&lt;/P&gt;&lt;P&gt;1.I have a json object as content.payload{} and need to extract the values inside the payload.Already splunk extract field as content.payload{} and the result as&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;SPAN class=""&gt;AP&lt;/SPAN&gt; &lt;SPAN class=""&gt;Import&lt;/SPAN&gt; &lt;SPAN class=""&gt;flow&lt;/SPAN&gt; &lt;SPAN class=""&gt;related&lt;/SPAN&gt; &lt;SPAN class=""&gt;results&lt;/SPAN&gt; &lt;SPAN class=""&gt;:&lt;/SPAN&gt; &lt;SPAN class=""&gt;Extract&lt;/SPAN&gt; &lt;SPAN class=""&gt;has&lt;/SPAN&gt; &lt;SPAN class=""&gt;no&lt;/SPAN&gt; &lt;SPAN class=""&gt;AP&lt;/SPAN&gt; &lt;SPAN class=""&gt;records&lt;/SPAN&gt; &lt;SPAN class=""&gt;to&lt;/SPAN&gt; &lt;SPAN class=""&gt;Import&lt;/SPAN&gt; &lt;SPAN class=""&gt;into&lt;/SPAN&gt; &lt;SPAN class=""&gt;Oracle&lt;/SPAN&gt;&lt;SPAN&gt;".&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;&lt;SPAN&gt;But I want to extract all the details inside the content.payload. How can extract from splunk query or from props.conf file.I tried spath but cant able to get it.&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;&lt;SPAN&gt;2.How to rename wildcard value of content.payload{}* ?&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;"content" : {
    "jobName" : "AP2",
    "region" : "NA",
    "payload" : [ {
      "GL Import flow processing results" : [ {
        "concurBatchId" : "4",
        "batchId" : "6",
        "count" : "50",
        "impConReqId" : "1",
        "errorMessage" : null,
        "filename" : "CONCUR_GL.csv"
      } ]
    }, "AP Import flow related results : Extract has no AP records to Import into Oracle" ]
  },&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 06 Mar 2024 15:34:08 GMT</pubDate>
    <dc:creator>karthi2809</dc:creator>
    <dc:date>2024-03-06T15:34:08Z</dc:date>
    <item>
      <title>How to extract Json array ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-Json-array/m-p/679825#M232384</link>
      <description>&lt;P&gt;Thanks in Advance.&lt;/P&gt;&lt;P&gt;1.I have a json object as content.payload{} and need to extract the values inside the payload.Already splunk extract field as content.payload{} and the result as&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;SPAN class=""&gt;AP&lt;/SPAN&gt; &lt;SPAN class=""&gt;Import&lt;/SPAN&gt; &lt;SPAN class=""&gt;flow&lt;/SPAN&gt; &lt;SPAN class=""&gt;related&lt;/SPAN&gt; &lt;SPAN class=""&gt;results&lt;/SPAN&gt; &lt;SPAN class=""&gt;:&lt;/SPAN&gt; &lt;SPAN class=""&gt;Extract&lt;/SPAN&gt; &lt;SPAN class=""&gt;has&lt;/SPAN&gt; &lt;SPAN class=""&gt;no&lt;/SPAN&gt; &lt;SPAN class=""&gt;AP&lt;/SPAN&gt; &lt;SPAN class=""&gt;records&lt;/SPAN&gt; &lt;SPAN class=""&gt;to&lt;/SPAN&gt; &lt;SPAN class=""&gt;Import&lt;/SPAN&gt; &lt;SPAN class=""&gt;into&lt;/SPAN&gt; &lt;SPAN class=""&gt;Oracle&lt;/SPAN&gt;&lt;SPAN&gt;".&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;&lt;SPAN&gt;But I want to extract all the details inside the content.payload. How can extract from splunk query or from props.conf file.I tried spath but cant able to get it.&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;&lt;SPAN&gt;2.How to rename wildcard value of content.payload{}* ?&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;"content" : {
    "jobName" : "AP2",
    "region" : "NA",
    "payload" : [ {
      "GL Import flow processing results" : [ {
        "concurBatchId" : "4",
        "batchId" : "6",
        "count" : "50",
        "impConReqId" : "1",
        "errorMessage" : null,
        "filename" : "CONCUR_GL.csv"
      } ]
    }, "AP Import flow related results : Extract has no AP records to Import into Oracle" ]
  },&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Mar 2024 15:34:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-Json-array/m-p/679825#M232384</guid>
      <dc:creator>karthi2809</dc:creator>
      <dc:date>2024-03-06T15:34:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract Json array ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-Json-array/m-p/679837#M232386</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/205249"&gt;@karthi2809&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;for this sourcetype use INDEXED_EXTRACTIONS = json in the sourcetype definitions (for more infos see at&amp;nbsp;&lt;A href="http://docs.splunk.com/Documentation/Splunk/9.2.0/admin/Propsconf" target="_blank"&gt;http://docs.splunk.com/Documentation/Splunk/9.2.0/admin/Propsconf&lt;/A&gt;)&lt;/P&gt;&lt;P&gt;othrwise, use the spath command&amp;nbsp;&lt;A href="https://docs.splunk.com/Documentation/Splunk/9.2.0/SearchReference/Spath" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/9.2.0/SearchReference/Spath&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 06 Mar 2024 16:07:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-Json-array/m-p/679837#M232386</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2024-03-06T16:07:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract Json array ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-Json-array/m-p/679851#M232397</link>
      <description>&lt;P&gt;I doubt if Splunk has truly extracted JSON array content.payload{}. &amp;nbsp;As you observed, Splunk gives you a flattened structure of the array. &amp;nbsp;As&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;&amp;nbsp;said, spath is the right tool. &amp;nbsp;The syntax is&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| spath content.payload{}
| mvexpand content.payload{}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Normally, you can then continue to use spath to extract content.payload{} after this. &amp;nbsp;But your data has another layer of array. &amp;nbsp;That's not usually a problem. &amp;nbsp;But then, your developers did you a great injustice by using actual data values (e.g., &lt;SPAN&gt;"GL Import flow processing results")&lt;/SPAN&gt;&amp;nbsp;as JSON key. &amp;nbsp;Not only is this data, but the key name included major SPL breakers. &amp;nbsp;I haven't found a method to use spath to handle this. &amp;nbsp;If you have any influence over your developers, insist that they change&amp;nbsp;&lt;SPAN&gt;"GL Import flow processing results" to a value and assign it an appropriate key such as "workflow". &amp;nbsp;Otherwise, your trouble will be endless.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Luckily, Splunk introduced &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Fromjson" target="_blank" rel="noopener"&gt;from_json&lt;/A&gt; in 9.0. &amp;nbsp;If you use 9+, you can work around this temporarily before your developers take action.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| spath path=content.payload{}
| mvexpand content.payload{}
| fromjson content.payload{}
| mvexpand "GL Import flow processing results"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You sample data should give you&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;GL Import flow processing results&lt;/TD&gt;&lt;TD&gt;content.payload{}&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;{"concurBatchId":"4","batchId":"6","count":"50","impConReqId":"1","errorMessage":null,"filename":"CONCUR_GL.csv"}&lt;/TD&gt;&lt;TD&gt;{ "GL Import flow processing results" : [ { "concurBatchId" : "4", "batchId" : "6", "count" : "50", "impConReqId" : "1", "errorMessage" : null, "filename" : "CONCUR_GL.csv" } ] }&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;AP Import flow related results : Extract has no AP records to Import into Oracle&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;(Scroll right to see other columns.)&lt;/P&gt;&lt;P&gt;This is an emulation for you to play with and compare with real data&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval _raw = "{
\"content\" : {
    \"jobName\" : \"AP2\",
    \"region\" : \"NA\",
    \"payload\" : [ {
      \"GL Import flow processing results\" : [ {
        \"concurBatchId\" : \"4\",
        \"batchId\" : \"6\",
        \"count\" : \"50\",
        \"impConReqId\" : \"1\",
        \"errorMessage\" : null,
        \"filename\" : \"CONCUR_GL.csv\"
      } ]
    }, \"AP Import flow related results : Extract has no AP records to Import into Oracle\" ]
  }
}"
``` data emulation above ```&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Mar 2024 17:51:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-Json-array/m-p/679851#M232397</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2024-03-06T17:51:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract Json array ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-Json-array/m-p/680234#M232513</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;/P&gt;&lt;P&gt;Working as expected &lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Mar 2024 05:03:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-Json-array/m-p/680234#M232513</guid>
      <dc:creator>karthi2809</dc:creator>
      <dc:date>2024-03-11T05:03:36Z</dc:date>
    </item>
  </channel>
</rss>

