<?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: json export / escaped characters in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/json-export-escaped-characters/m-p/438318#M76434</link>
    <description>&lt;P&gt;No, it is &lt;EM&gt;not&lt;/EM&gt; how you assemble the JSON.  You are doing it manually and incorrectly.  Doing it &lt;EM&gt;my&lt;/EM&gt; way will create correct, coherent, and properly-escaped/encapsulated JSON which will be easy to export/import.  Just try it.&lt;/P&gt;</description>
    <pubDate>Sun, 23 Jun 2019 22:58:16 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2019-06-23T22:58:16Z</dc:date>
    <item>
      <title>json export / escaped characters</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/json-export-escaped-characters/m-p/438315#M76431</link>
      <description>&lt;P&gt;I try to export data from Splunk. It is important that this data is not changed/manipulated by the export/Splunk itself. &lt;/P&gt;

&lt;P&gt;" and \  are a problem here.&lt;/P&gt;

&lt;P&gt;Example:&lt;BR /&gt;
&lt;CODE&gt;&lt;BR /&gt;
    | makeresults | eval SkriptBlockText="\"s0m3\\Code\""&lt;BR /&gt;
    | table _time SkriptBlockText&lt;BR /&gt;
&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;The value ist &lt;CODE&gt;"s0m3\Code"&lt;/CODE&gt;.  When exporting, the characters are escaped &lt;CODE&gt;\"s0m3\\Code\"&lt;/CODE&gt;. This affects the result of the subsequent analysis, from a security point of view.&lt;/P&gt;

&lt;P&gt;My exportscript.ps1:&lt;BR /&gt;
`&lt;BR /&gt;
$search = '| makeresults | eval SkriptBlockText="\"s0m3\Code\"" | table _time SkriptBlockText'&lt;/P&gt;

&lt;P&gt;$url = '&lt;A href="https://YOUR_URL:8089/services/search/jobs/export" target="_blank"&gt;https://YOUR_URL:8089/services/search/jobs/export&lt;/A&gt;'&lt;BR /&gt;
$credential = get-credential&lt;BR /&gt;
$outfile = '.\output-'+$(get-date -f yyyy-MM-dd-hh-mm)+'.json'&lt;/P&gt;

&lt;H1&gt;This will allow for self-signed SSL certs to work&lt;/H1&gt;

&lt;P&gt;[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}&lt;BR /&gt;
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls &lt;/P&gt;

&lt;P&gt;$Body = @{&lt;BR /&gt;
    search = $search&lt;BR /&gt;
    output_mode = 'json'&lt;BR /&gt;
    exec_mode = 'oneshot'&lt;BR /&gt;
    count = '0'&lt;BR /&gt;
    }&lt;BR /&gt;
Invoke-RestMethod -Uri $url -Credential $credential -Method Post -OutFile $outfile -Body $Body&lt;BR /&gt;
`&lt;/P&gt;

&lt;P&gt;Perhaps the method is not the right one, does anyone have an idea or a solution to the problem?&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 01:01:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/json-export-escaped-characters/m-p/438315#M76431</guid>
      <dc:creator>twjack</dc:creator>
      <dc:date>2020-09-30T01:01:48Z</dc:date>
    </item>
    <item>
      <title>Re: json export / escaped characters</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/json-export-escaped-characters/m-p/438316#M76432</link>
      <description>&lt;P&gt;Check out &lt;CODE&gt;JSON Tools&lt;/CODE&gt; app:&lt;BR /&gt;
&lt;A href="https://github.com/doksu/TA-jsontools/wiki"&gt;https://github.com/doksu/TA-jsontools/wiki&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Multi-value field preservation when exporting to csv&lt;BR /&gt;
Fields with multiple values can be easily preserved when exporting to csv. For example, we can convert a single field to JSON:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | mkjson outputfield=src src | outputlookup mylookup
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This can then be reconstituted with spath:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | lookup mylookup ... OUTPUT src | spath input=src
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This is useful to migrate KV Store Collection records from one host to another (or to a SHC), but be mindful of the fact spath removes any preceding underscore from field names. For example, to export Enterprise Security's Notable Event lookup to a csv containing JSON, the following could be used:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup es_notable_events
| mkjson includehidden=true outputfield=json
| table json
| outputlookup migration_es_notable_events
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If the flat-file csv lookup is then migrated, it can be used to re-populate the contents of the KV Store without loss of fidelity (multi-value fields, etc.) but the fields beginning with an underscore must be renamed:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup migration_es_notable_events
| spath input=json
| rename key as _key
| rename time as _time
| outputlookup es_notable_events
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 23 Jun 2019 02:37:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/json-export-escaped-characters/m-p/438316#M76432</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-06-23T02:37:15Z</dc:date>
    </item>
    <item>
      <title>Re: json export / escaped characters</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/json-export-escaped-characters/m-p/438317#M76433</link>
      <description>&lt;P&gt;That's how I assemble json at searchtime....    &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;| foreach * &lt;BR /&gt;
        [ eval jsonmv_ = mvappend(jsonmv_,"\"&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;\":\"" + &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; + "\"")] &lt;BR /&gt;
    | eval json_raw = "{" + mvjoin(jsonmv_,",") + "}" &lt;BR /&gt;
    | fields - jsonmv_ &lt;BR /&gt;
&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;That not the problem. It's a problem that the characters &lt;CODE&gt;"&lt;/CODE&gt; and &lt;CODE&gt;\\&lt;/CODE&gt; are escaped when exporting the data.&lt;/P&gt;

&lt;P&gt;Sorry if I have expressed myself a little unclear or complicated here. , My English is not so good...&lt;/P&gt;

&lt;P&gt;I need a method to export the data without the backslashes being added. Only the data, raw and unchanged.&lt;/P&gt;

&lt;P&gt;The addon is more practical for other things but in this case it does exactly what I don't want it to do, it escapes (adds backslashes) the data already at search time.&lt;/P&gt;</description>
      <pubDate>Sun, 23 Jun 2019 19:20:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/json-export-escaped-characters/m-p/438317#M76433</guid>
      <dc:creator>twjack</dc:creator>
      <dc:date>2019-06-23T19:20:13Z</dc:date>
    </item>
    <item>
      <title>Re: json export / escaped characters</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/json-export-escaped-characters/m-p/438318#M76434</link>
      <description>&lt;P&gt;No, it is &lt;EM&gt;not&lt;/EM&gt; how you assemble the JSON.  You are doing it manually and incorrectly.  Doing it &lt;EM&gt;my&lt;/EM&gt; way will create correct, coherent, and properly-escaped/encapsulated JSON which will be easy to export/import.  Just try it.&lt;/P&gt;</description>
      <pubDate>Sun, 23 Jun 2019 22:58:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/json-export-escaped-characters/m-p/438318#M76434</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-06-23T22:58:16Z</dc:date>
    </item>
    <item>
      <title>Re: json export / escaped characters</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/json-export-escaped-characters/m-p/438319#M76435</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;properly-escaped/encapsulated JSON&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;Thank you for your willingness to help me but..I need the data without "proberly-escaped/encapsulated". If the field value is &lt;CODE&gt;"S0m3\Code"&lt;/CODE&gt;, i need exacly this in my export. &lt;/P&gt;

&lt;P&gt;I tested the addon, it does exactly what I don't need.&lt;/P&gt;

&lt;P&gt;In the following, it is intended to analyze "Powershell ScriptBlockLogging" for obfuscations and any added character will falsify the results.&lt;/P&gt;</description>
      <pubDate>Sun, 23 Jun 2019 23:21:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/json-export-escaped-characters/m-p/438319#M76435</guid>
      <dc:creator>twjack</dc:creator>
      <dc:date>2019-06-23T23:21:38Z</dc:date>
    </item>
    <item>
      <title>Re: json export / escaped characters</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/json-export-escaped-characters/m-p/438320#M76436</link>
      <description>&lt;P&gt;It may be easier to run the splunk search from the search head inside of your powershell script.  Did you know that you can run a Splunk search from your powershell script?  Try this from &lt;CODE&gt;cmd.exe&lt;/CODE&gt; and then migrate it inside of your script:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;C:\Program*Files\Splunk\bin\Splunk.exe "Your Splunk search here"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 24 Jun 2019 00:09:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/json-export-escaped-characters/m-p/438320#M76436</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-06-24T00:09:20Z</dc:date>
    </item>
  </channel>
</rss>

