<?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 format as fields? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-Extract-JSON-format-as-fields/m-p/586350#M204265</link>
    <description>&lt;P&gt;&lt;SPAN&gt;Need to extract json file in fields&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;{

"AAA":

{

"modified_files": [ "\"b/C:\\\\/HEAD\"",

"\"b/C:\\\\/dev\"",

"\"b/C:\\\\HEAD\"" ]

},

"BBB":

{

"modified_files": [ "\"b/C:\\\\/HEAD\"",

"\"b/C:\\\\/dev\"",

"\"b/C:\\\\HEAD\"" ]

}

}&lt;/LI-CODE&gt;
&lt;P&gt;&lt;SPAN&gt;Expected Output as:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;AAA,BBB is application name&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;eg:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Application: AAA&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thanks in advance&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 24 Feb 2022 14:41:04 GMT</pubDate>
    <dc:creator>karthi2809</dc:creator>
    <dc:date>2022-02-24T14:41:04Z</dc:date>
    <item>
      <title>How to Extract JSON format as fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Extract-JSON-format-as-fields/m-p/586350#M204265</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Need to extract json file in fields&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;{

"AAA":

{

"modified_files": [ "\"b/C:\\\\/HEAD\"",

"\"b/C:\\\\/dev\"",

"\"b/C:\\\\HEAD\"" ]

},

"BBB":

{

"modified_files": [ "\"b/C:\\\\/HEAD\"",

"\"b/C:\\\\/dev\"",

"\"b/C:\\\\HEAD\"" ]

}

}&lt;/LI-CODE&gt;
&lt;P&gt;&lt;SPAN&gt;Expected Output as:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;AAA,BBB is application name&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;eg:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Application: AAA&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thanks in advance&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Feb 2022 14:41:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Extract-JSON-format-as-fields/m-p/586350#M204265</guid>
      <dc:creator>karthi2809</dc:creator>
      <dc:date>2022-02-24T14:41:04Z</dc:date>
    </item>
    <item>
      <title>Re: Need to Extract JSON formate as fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Extract-JSON-format-as-fields/m-p/586410#M204280</link>
      <description>&lt;P&gt;if you already ingested this data and have the sourcetype as _json&amp;nbsp;&lt;/P&gt;&lt;P&gt;you can use the following query&amp;nbsp;&lt;/P&gt;&lt;P&gt;sourcetype=_json |rex max_match=0 field=_raw "\"(?&amp;lt;application&amp;gt;\w+)\":\s\n"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="venky1544_0-1645706100581.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/18115i9F053684A0DF2C03/image-size/medium?v=v2&amp;amp;px=400" role="button" title="venky1544_0-1645706100581.png" alt="venky1544_0-1645706100581.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Feb 2022 12:35:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Extract-JSON-format-as-fields/m-p/586410#M204280</guid>
      <dc:creator>venky1544</dc:creator>
      <dc:date>2022-02-24T12:35:27Z</dc:date>
    </item>
    <item>
      <title>Re: Need to Extract JSON formate as fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Extract-JSON-format-as-fields/m-p/586441#M204284</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/137142"&gt;@venky1544&lt;/a&gt;&amp;nbsp;Thanks for the solution .But i am not getting application name as fields.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Feb 2022 15:51:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Extract-JSON-format-as-fields/m-p/586441#M204284</guid>
      <dc:creator>karthi2809</dc:creator>
      <dc:date>2022-02-24T15:51:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to Extract JSON format as fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Extract-JSON-format-as-fields/m-p/586453#M204286</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/205249"&gt;@karthi2809&lt;/a&gt;&amp;nbsp; Hey&amp;nbsp;&lt;/P&gt;&lt;P&gt;it could be that the JSON you pasted here is bit different than your original data. formats usually get changed like an added space or newlines when you copy paste if you could attach a sample file here probably can see why the query is not working and what is the sourcetype of your data is it _json ??&lt;/P&gt;</description>
      <pubDate>Thu, 24 Feb 2022 16:36:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Extract-JSON-format-as-fields/m-p/586453#M204286</guid>
      <dc:creator>venky1544</dc:creator>
      <dc:date>2022-02-24T16:36:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to Extract JSON format as fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Extract-JSON-format-as-fields/m-p/586550#M204312</link>
      <description>&lt;P&gt;Is this something you are looking for?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| foreach *.modified_files{}
    [ eval application=mvappend(application,"&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;" . "|" . mvjoin('&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;.modified_files{}', "|"))]
| fields application
| mvexpand application
| eval application = split(application, "|")
| eval application.modified_files=mvindex(application,1,-1), application.name=mvindex(application,0)
| table application.*&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here, I assume that your indexed JSON has already been extracted, i.e., "flattened" into fields like AAA.modified_files{} and BBB.modified_files{}. &amp;nbsp;If not, add |spath to do so.&lt;/P&gt;&lt;P&gt;The sample input gives the following:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="270px"&gt;&lt;DIV class=""&gt;application.modified_files&lt;/DIV&gt;&lt;/TD&gt;&lt;TD width="42.484375px"&gt;application.name&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="270px"&gt;&lt;DIV class=""&gt;"b/C:\/HEAD"&lt;/DIV&gt;&lt;DIV class=""&gt;"b/C:\/dev"&lt;/DIV&gt;&lt;DIV class=""&gt;"b/C:\HEAD"&lt;/DIV&gt;&lt;/TD&gt;&lt;TD width="42.484375px"&gt;AAA&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="270px"&gt;&lt;DIV class=""&gt;"b/C:\/HEAD"&lt;/DIV&gt;&lt;DIV class=""&gt;"b/C:\/dev"&lt;/DIV&gt;&lt;DIV class=""&gt;"b/C:\HEAD"&lt;/DIV&gt;&lt;/TD&gt;&lt;TD width="42.484375px"&gt;BBB&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Fri, 25 Feb 2022 07:52:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Extract-JSON-format-as-fields/m-p/586550#M204312</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2022-02-25T07:52:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to Extract JSON format as fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Extract-JSON-format-as-fields/m-p/586825#M204385</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/33901"&gt;@yuanliu&lt;/a&gt;&amp;nbsp;i have another query by using your query its giving dynamic fields and how can i get the&amp;nbsp; counts of the dynamic fields.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Feb 2022 11:43:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Extract-JSON-format-as-fields/m-p/586825#M204385</guid>
      <dc:creator>karthi2809</dc:creator>
      <dc:date>2022-02-28T11:43:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to Extract JSON format as fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Extract-JSON-format-as-fields/m-p/586836#M204389</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/33901"&gt;@yuanliu&lt;/a&gt;&amp;nbsp;In my json file i have another application which modified field is empty but now the application ccc is not extracting as application.&lt;/P&gt;&lt;P&gt;Thanks&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{
"AAA":
{
"modified_files": [ "\"b/C:\\\\/HEAD\"",
                    "\"b/C:\\\\/dev\"",
                    "\"b/C:\\\\HEAD\"" ]
},
"BBB":
{
"modified_files": [ "\"b/C:\\\\/HEAD\"",
                    "\"b/C:\\\\/dev\"",
                    "\"b/C:\\\\HEAD\"" ]
},
"CCC":
{
"modified_files": [
 ]
}
}&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>Mon, 28 Feb 2022 12:41:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Extract-JSON-format-as-fields/m-p/586836#M204389</guid>
      <dc:creator>karthi2809</dc:creator>
      <dc:date>2022-02-28T12:41:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to Extract JSON format as fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Extract-JSON-format-as-fields/m-p/586879#M204403</link>
      <description>&lt;P&gt;Splunk doesn't output anything with empty array (bug?). &amp;nbsp;In the past, I used sed to add a distinct string to represent empty arrays. &amp;nbsp;This will work if you accept the cost of extra extraction.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex mode=sed "s/\[\s*\]/[\"\"]/"
| spath
| foreach *.modified_files{}
    [ eval application=mvappend(application,"&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;" . "|" . mvjoin('&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;.modified_files{}', "|"))]
| fields application
| mvexpand application
| eval application = split(application, "|")
| eval application.modified_files=mvindex(application,1,-1), application.name=mvindex(application,0)
| table application.*&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here, AAA.modified_files{} and BBB.modified_files{} are already extracted when you do your search, but they are discarded. &amp;nbsp;They get extracted once more in SPL after you fake the empty array.&lt;/P&gt;&lt;P&gt;Output from sample data:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="240px"&gt;&lt;DIV class=""&gt;application.modified_files&lt;/DIV&gt;&lt;/TD&gt;&lt;TD width="64px"&gt;application.name&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="240px"&gt;&lt;DIV class=""&gt;"b/C:\/HEAD"&lt;/DIV&gt;&lt;DIV class=""&gt;"b/C:\/dev"&lt;/DIV&gt;&lt;DIV class=""&gt;"b/C:\HEAD"&lt;/DIV&gt;&lt;/TD&gt;&lt;TD width="64px"&gt;AAA&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="240px"&gt;&lt;DIV class=""&gt;"b/C:\/HEAD"&lt;/DIV&gt;&lt;DIV class=""&gt;"b/C:\/dev"&lt;/DIV&gt;&lt;DIV class=""&gt;"b/C:\HEAD"&lt;/DIV&gt;&lt;/TD&gt;&lt;TD width="64px"&gt;BBB&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="240px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="64px"&gt;CCC&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Mon, 28 Feb 2022 17:32:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Extract-JSON-format-as-fields/m-p/586879#M204403</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2022-02-28T17:32:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to Extract JSON format as fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Extract-JSON-format-as-fields/m-p/586925#M204412</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/33901"&gt;@yuanliu&lt;/a&gt;&amp;nbsp; perfect Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Mar 2022 04:53:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Extract-JSON-format-as-fields/m-p/586925#M204412</guid>
      <dc:creator>karthi2809</dc:creator>
      <dc:date>2022-03-01T04:53:28Z</dc:date>
    </item>
  </channel>
</rss>

