<?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 remove characters in my json raw data so it can be indexed in son formate? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-to-remove-characters-in-my-json-raw-data-so-it-can-be/m-p/244078#M47245</link>
    <description>&lt;P&gt;Your data has four sets of &lt;CODE&gt;"&lt;/CODE&gt;, basically &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;{"&lt;/CODE&gt; which starts the json&lt;BR /&gt;
&lt;CODE&gt;":"&lt;/CODE&gt; which divides a key and value&lt;BR /&gt;
&lt;CODE&gt;","&lt;/CODE&gt; which divides one key value pair from another&lt;BR /&gt;
&lt;CODE&gt;"}&lt;/CODE&gt; which ends your json data.&lt;/P&gt;

&lt;P&gt;Every &lt;CODE&gt;"&lt;/CODE&gt; besides the above four combinations (assumption based on above data) can be safely removed. Based on this can you try this in your &lt;CODE&gt;props.conf&lt;/CODE&gt; as it seems to be working in my local with the above dataset:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[your:sourcetype]
 SEDCMD-rep_1 = s/{"/{'/g
 SEDCMD-rep_2 = s/":"/':'/g
 SEDCMD-rep_3 = s/","/','/g
 SEDCMD-rep_4 = s/"}/'}/g
 SEDCMD-rep_5 = s/"//g
 SEDCMD-rep_6 = s/'/"/g
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Above &lt;CODE&gt;SEDCMD&lt;/CODE&gt; portion should be added in addition to other &lt;CODE&gt;properties/settings&lt;/CODE&gt; you already might be having for &lt;CODE&gt;your:sourcetype&lt;/CODE&gt;. These six lines above do not represent the only ones to be put in, so please do not delete the other properties for &lt;CODE&gt;your:sourcetype&lt;/CODE&gt; which might already be present like &lt;CODE&gt;PREFIX_SOURCETYPE&lt;/CODE&gt; &lt;CODE&gt;SHOULD_LINEMERGE&lt;/CODE&gt; etc.&lt;/P&gt;

&lt;P&gt;Logic above is to remove each group of &lt;CODE&gt;"&lt;/CODE&gt; one at a time in combination with other &lt;CODE&gt;{ or : or ,&lt;/CODE&gt; and replace with &lt;CODE&gt;single quote&lt;/CODE&gt; to keep the json structure. Then in the end once all the above four groups of double quotes are replaced with single quotes, replace all the remaining &lt;CODE&gt;"&lt;/CODE&gt; with blank. &lt;/P&gt;

&lt;P&gt;Once all the &lt;CODE&gt;"&lt;/CODE&gt; are replaced either with single quote or blank, now it is a good time for &lt;CODE&gt;SEDCMD-rep_6 = s/'/"/g&lt;/CODE&gt; to replace back all the &lt;CODE&gt;single quotes&lt;/CODE&gt; with &lt;CODE&gt;double quotes&lt;/CODE&gt;  to restore your json format.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;NOTE:&lt;/STRONG&gt; You can use any other symbol like &lt;CODE&gt;~&lt;/CODE&gt; rather than &lt;CODE&gt;single quote&lt;/CODE&gt; in above &lt;CODE&gt;sed replacements&lt;/CODE&gt;if you feel &lt;CODE&gt;single quote&lt;/CODE&gt; can be part of your data.&lt;/P&gt;</description>
    <pubDate>Tue, 22 Nov 2016 05:37:06 GMT</pubDate>
    <dc:creator>gokadroid</dc:creator>
    <dc:date>2016-11-22T05:37:06Z</dc:date>
    <item>
      <title>How to remove characters in my json raw data so it can be indexed in son formate?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-remove-characters-in-my-json-raw-data-so-it-can-be/m-p/244077#M47244</link>
      <description>&lt;P&gt;{"ts":"11 03 2016 06:03:56.390","th":"sample-product","user":"apple","device":"iphone","errorCode":"","level":"INFO","msg":"Publishing event to cache "TimeZones" with message "Message@4eedf6e5"."} &lt;/P&gt;

&lt;P&gt;If we remove the quotes for TimeZones and Message@4eedf6e5 it will be converted as son formate as below &lt;/P&gt;

&lt;P&gt;{&lt;BR /&gt;
"ts":"11 03 2016 06:03:56.390",&lt;BR /&gt;
"th":"sample-product",&lt;BR /&gt;
"user":"apple",&lt;BR /&gt;
"device":"iphone",&lt;BR /&gt;
"errorCode":"",&lt;BR /&gt;
"level":"INFO",&lt;BR /&gt;
"msg":"Publishing event to cache TimeZones with message &lt;A href="mailto:Message@4eedf6e5"&gt;Message@4eedf6e5&lt;/A&gt;."&lt;BR /&gt;
}&lt;/P&gt;

&lt;P&gt;Can someone could help me out in this....&lt;BR /&gt;
Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Nov 2016 00:48:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-remove-characters-in-my-json-raw-data-so-it-can-be/m-p/244077#M47244</guid>
      <dc:creator>appache</dc:creator>
      <dc:date>2016-11-22T00:48:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove characters in my json raw data so it can be indexed in son formate?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-remove-characters-in-my-json-raw-data-so-it-can-be/m-p/244078#M47245</link>
      <description>&lt;P&gt;Your data has four sets of &lt;CODE&gt;"&lt;/CODE&gt;, basically &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;{"&lt;/CODE&gt; which starts the json&lt;BR /&gt;
&lt;CODE&gt;":"&lt;/CODE&gt; which divides a key and value&lt;BR /&gt;
&lt;CODE&gt;","&lt;/CODE&gt; which divides one key value pair from another&lt;BR /&gt;
&lt;CODE&gt;"}&lt;/CODE&gt; which ends your json data.&lt;/P&gt;

&lt;P&gt;Every &lt;CODE&gt;"&lt;/CODE&gt; besides the above four combinations (assumption based on above data) can be safely removed. Based on this can you try this in your &lt;CODE&gt;props.conf&lt;/CODE&gt; as it seems to be working in my local with the above dataset:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[your:sourcetype]
 SEDCMD-rep_1 = s/{"/{'/g
 SEDCMD-rep_2 = s/":"/':'/g
 SEDCMD-rep_3 = s/","/','/g
 SEDCMD-rep_4 = s/"}/'}/g
 SEDCMD-rep_5 = s/"//g
 SEDCMD-rep_6 = s/'/"/g
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Above &lt;CODE&gt;SEDCMD&lt;/CODE&gt; portion should be added in addition to other &lt;CODE&gt;properties/settings&lt;/CODE&gt; you already might be having for &lt;CODE&gt;your:sourcetype&lt;/CODE&gt;. These six lines above do not represent the only ones to be put in, so please do not delete the other properties for &lt;CODE&gt;your:sourcetype&lt;/CODE&gt; which might already be present like &lt;CODE&gt;PREFIX_SOURCETYPE&lt;/CODE&gt; &lt;CODE&gt;SHOULD_LINEMERGE&lt;/CODE&gt; etc.&lt;/P&gt;

&lt;P&gt;Logic above is to remove each group of &lt;CODE&gt;"&lt;/CODE&gt; one at a time in combination with other &lt;CODE&gt;{ or : or ,&lt;/CODE&gt; and replace with &lt;CODE&gt;single quote&lt;/CODE&gt; to keep the json structure. Then in the end once all the above four groups of double quotes are replaced with single quotes, replace all the remaining &lt;CODE&gt;"&lt;/CODE&gt; with blank. &lt;/P&gt;

&lt;P&gt;Once all the &lt;CODE&gt;"&lt;/CODE&gt; are replaced either with single quote or blank, now it is a good time for &lt;CODE&gt;SEDCMD-rep_6 = s/'/"/g&lt;/CODE&gt; to replace back all the &lt;CODE&gt;single quotes&lt;/CODE&gt; with &lt;CODE&gt;double quotes&lt;/CODE&gt;  to restore your json format.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;NOTE:&lt;/STRONG&gt; You can use any other symbol like &lt;CODE&gt;~&lt;/CODE&gt; rather than &lt;CODE&gt;single quote&lt;/CODE&gt; in above &lt;CODE&gt;sed replacements&lt;/CODE&gt;if you feel &lt;CODE&gt;single quote&lt;/CODE&gt; can be part of your data.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Nov 2016 05:37:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-remove-characters-in-my-json-raw-data-so-it-can-be/m-p/244078#M47245</guid>
      <dc:creator>gokadroid</dc:creator>
      <dc:date>2016-11-22T05:37:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove characters in my json raw data so it can be indexed in son formate?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-remove-characters-in-my-json-raw-data-so-it-can-be/m-p/244079#M47246</link>
      <description>&lt;P&gt;Thankyou for you quick response, but there is no difference in my data its still the same i have tried masking another fields also but even that didnt work and also i have tried indexed_extractions=json. Is there any other way to do it.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Nov 2016 14:55:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-remove-characters-in-my-json-raw-data-so-it-can-be/m-p/244079#M47246</guid>
      <dc:creator>appache</dc:creator>
      <dc:date>2016-11-23T14:55:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove characters in my json raw data so it can be indexed in son formate?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-remove-characters-in-my-json-raw-data-so-it-can-be/m-p/244080#M47247</link>
      <description>&lt;P&gt;this is how my props.conf showed up:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[multixyz]
SEDCMD-rep_1 = s/{"/{'/g
SEDCMD-rep_2 = s/":"/':'/g
SEDCMD-rep_3 = s/","/','/g
SEDCMD-rep_4 = s/"}/'}/g
SEDCMD-rep_5 = s/"//g
SEDCMD-rep_6 = s/'/"/g
DATETIME_CONFIG = 
NO_BINARY_CHECK = true
category = Custom
pulldown_type = true
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This is how my inputs.conf showed up which sorted &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[tcp://12125]
connection_host = dns
index = multixyzjson
sourcetype = multixyz
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;These were my events which were fed:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;{"ts":"11 03 2016 06:03:56.390","th":"sample-product","user":"apple","device":"iphone","errorCode":"","level":"INFO","msg":"Publishing event to cache "TimeZones" with message "Message@4eedf6e5"."}&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Nov 2016 15:52:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-remove-characters-in-my-json-raw-data-so-it-can-be/m-p/244080#M47247</guid>
      <dc:creator>gokadroid</dc:creator>
      <dc:date>2016-11-23T15:52:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove characters in my json raw data so it can be indexed in son formate?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-remove-characters-in-my-json-raw-data-so-it-can-be/m-p/244081#M47248</link>
      <description>&lt;P&gt;Thankyou gokadroid Got it &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;/P&gt;</description>
      <pubDate>Wed, 23 Nov 2016 16:36:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-remove-characters-in-my-json-raw-data-so-it-can-be/m-p/244081#M47248</guid>
      <dc:creator>appache</dc:creator>
      <dc:date>2016-11-23T16:36:55Z</dc:date>
    </item>
  </channel>
</rss>

