<?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: How to parse a path request string in json format? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-parse-a-path-request-string-in-json-format/m-p/671860#M230212</link>
    <description>Thanks. I tried but the scenario is a little bit complex ^^</description>
    <pubDate>Thu, 14 Dec 2023 08:44:14 GMT</pubDate>
    <dc:creator>EricMonkeyKing</dc:creator>
    <dc:date>2023-12-14T08:44:14Z</dc:date>
    <item>
      <title>How to parse a path request string in json format?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-parse-a-path-request-string-in-json-format/m-p/671681#M230146</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;For this sort of json string, how can I extract &lt;STRONG&gt;KeyA, KeyB, KeyC&lt;/STRONG&gt;?&amp;nbsp;&lt;/P&gt;&lt;P&gt;{ "KeyA": [ { "path": "/attibuteA", "op": "replace", "value": "hello" }, { "path": "/attibuteB", "op": "replace", "value": "hi" } ], "KeyB": [ { "path": "/attibuteA", "op": "replace", "value": "" }, { "path": "/attibuteC", "op": "replace", "value": "hey" }, { "path": "/attibuteD", "op": "replace", "value": "hello" } ], "KeyC": [ { "path": "/attibuteE", "op": "replace", "value": "" } ] }&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My ideal output would look like：&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD height="25px"&gt;Key&lt;/TD&gt;&lt;TD height="25px"&gt;path&lt;/TD&gt;&lt;TD height="25px"&gt;op&lt;/TD&gt;&lt;TD height="25px"&gt;value&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%" height="25px"&gt;KeyA&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;attibuteA&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;replace&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;hello&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%" height="25px"&gt;KeyA&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;attibuteB&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;replace&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;hi&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%" height="25px"&gt;KeyB&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;attibuteA&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;replace&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%" height="25px"&gt;KeyB&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;attibuteC&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;replace&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;hey&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="25px"&gt;KeyB&lt;/TD&gt;&lt;TD height="25px"&gt;attibuteD&lt;/TD&gt;&lt;TD height="25px"&gt;replace&lt;/TD&gt;&lt;TD height="25px"&gt;hello&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="25px"&gt;Keyc&lt;/TD&gt;&lt;TD height="25px"&gt;attibuteE&lt;/TD&gt;&lt;TD height="25px"&gt;replace&lt;/TD&gt;&lt;TD height="25px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks^&lt;/P&gt;</description>
      <pubDate>Wed, 13 Dec 2023 10:04:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-parse-a-path-request-string-in-json-format/m-p/671681#M230146</guid>
      <dc:creator>EricMonkeyKing</dc:creator>
      <dc:date>2023-12-13T10:04:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse a path request string in json format?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-parse-a-path-request-string-in-json-format/m-p/671687#M230147</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/263291"&gt;@EricMonkeyKing&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;did you configured INDEXED_EXTRACTIONS = json&amp;nbsp;for that sourcetype or used the spath command (&lt;A href="https://docs.splunk.com/Documentation/Splunk/9.1.2/SearchReference/Spath" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/9.1.2/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, 13 Dec 2023 10:11:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-parse-a-path-request-string-in-json-format/m-p/671687#M230147</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-12-13T10:11:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse a path request string in json format?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-parse-a-path-request-string-in-json-format/m-p/671745#M230162</link>
      <description>&lt;P&gt;Think I was able to get the table in the output you are wanting.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dtburrows3_0-1702480839496.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/28490i6AE6E84F803C9170/image-size/medium?v=v2&amp;amp;px=400" role="button" title="dtburrows3_0-1702480839496.png" alt="dtburrows3_0-1702480839496.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I was able to achieve this using this SPL.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
    | eval
        json_object="{ \"KeyA\": [ { \"path\": \"/attibuteA\", \"op\": \"replace\", \"value\": \"hello\" }, { \"path\": \"/attibuteB\", \"op\": \"replace\", \"value\": \"hi\" } ], \"KeyB\": [ { \"path\": \"/attibuteA\", \"op\": \"replace\", \"value\": \"\" }, { \"path\": \"/attibuteC\", \"op\": \"replace\", \"value\": \"hey\" }, { \"path\": \"/attibuteD\", \"op\": \"replace\", \"value\": \"hello\" } ], \"KeyC\": [ { \"path\": \"/attibuteE\", \"op\": \"replace\", \"value\": \"\" } ] }"
    | fields - _time
    | fromjson json_object
    | fields - json_object
    ``` Assuming that your fieldset at this point is only the list of fields needed for your final output ```
    ``` If there are other fields present that are not apart of the json object you are trying to parse then you should set up a naming convention for fields youy want to loop through ```
    | foreach *
        [
            | eval
                all_objects=mvappend(
                    'all_objects',
                    case(
                        isnull('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'), null(),
                        mvcount('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;')==1, json_set('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;', "Key", "&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;"),
                        mvcount('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;')&amp;gt;1, mvmap('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;', json_set('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;', "Key", "&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;"))
                        )
                    )
            ]
    | fields + all_objects
    | mvexpand all_objects
    | spath input=all_objects
    | fields - all_objects
    | fields + Key, path, op, value&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 13 Dec 2023 15:22:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-parse-a-path-request-string-in-json-format/m-p/671745#M230162</guid>
      <dc:creator>dtburrows3</dc:creator>
      <dc:date>2023-12-13T15:22:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse a path request string in json format?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-parse-a-path-request-string-in-json-format/m-p/671858#M230210</link>
      <description>Much appreciated! It works!</description>
      <pubDate>Thu, 14 Dec 2023 08:42:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-parse-a-path-request-string-in-json-format/m-p/671858#M230210</guid>
      <dc:creator>EricMonkeyKing</dc:creator>
      <dc:date>2023-12-14T08:42:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse a path request string in json format?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-parse-a-path-request-string-in-json-format/m-p/671860#M230212</link>
      <description>Thanks. I tried but the scenario is a little bit complex ^^</description>
      <pubDate>Thu, 14 Dec 2023 08:44:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-parse-a-path-request-string-in-json-format/m-p/671860#M230212</guid>
      <dc:creator>EricMonkeyKing</dc:creator>
      <dc:date>2023-12-14T08:44:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse a path request string in json format?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-parse-a-path-request-string-in-json-format/m-p/671863#M230214</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/263291"&gt;@EricMonkeyKing&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;good for you, see next time!&lt;/P&gt;&lt;P&gt;Ciao and happy splunking&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;&lt;P&gt;P.S.: Karma Points are appreciated by all the contributors &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Dec 2023 08:49:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-parse-a-path-request-string-in-json-format/m-p/671863#M230214</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-12-14T08:49:16Z</dc:date>
    </item>
  </channel>
</rss>

