<?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: Fix JSON format by replacing single quote and put into new field in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Fix-JSON-format-by-replacing-single-quote-and-put-into-new-field/m-p/674581#M230903</link>
    <description>&lt;P&gt;Maybe something like this?&lt;BR /&gt;&lt;BR /&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;&amp;lt;base_search&amp;gt;
    | eval
        employee_data=replace(replace(employee_data, "\'", "\""), "None", "\"None\"")
    | spath input=employee_data&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Testing on my local instance looks like it worked out.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dtburrows3_0-1705532665943.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/28981i16B79358D20C99FD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="dtburrows3_0-1705532665943.png" alt="dtburrows3_0-1705532665943.png" /&gt;&lt;/span&gt;&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="dtburrows3_2-1705532793823.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/28983iC9AC4FBCDC391D9D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="dtburrows3_2-1705532793823.png" alt="dtburrows3_2-1705532793823.png" /&gt;&lt;/span&gt;&lt;/P&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, 17 Jan 2024 23:06:42 GMT</pubDate>
    <dc:creator>dtburrows3</dc:creator>
    <dc:date>2024-01-17T23:06:42Z</dc:date>
    <item>
      <title>Fix JSON format by replacing single quote and put into new field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Fix-JSON-format-by-replacing-single-quote-and-put-into-new-field/m-p/674576#M230900</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;| dbxquery connection=test&amp;nbsp;query="select employee_data from company"&lt;BR /&gt;The following employee_data is not in proper JSON format, so I can't use spath.&lt;BR /&gt;How do I replace &lt;STRONG&gt;single quote (')&lt;/STRONG&gt; with &lt;STRONG&gt;double quote (")&lt;/STRONG&gt;, replace &lt;STRONG&gt;None&lt;/STRONG&gt; with &lt;STRONG&gt;"None"&lt;/STRONG&gt; and put it on a new field?&lt;BR /&gt;Thank you for your help.&lt;/P&gt;&lt;TABLE width="561px"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="560px"&gt;&lt;STRONG&gt;employee_data&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="560px"&gt;[{company':'company A','name': 'employee A1','position': None}, {company': 'company A','name': 'employee A2','position': None}]&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="560px"&gt;[{company':'company B','name': 'employee B1','position': None}, {company': 'company B','name': 'employee B2','position': None}]&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="560px"&gt;[{company':'company C','name': 'employee C1','position': None}, {company': 'company C','name': 'employee C2','position': None}]&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jan 2024 22:08:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Fix-JSON-format-by-replacing-single-quote-and-put-into-new-field/m-p/674576#M230900</guid>
      <dc:creator>LearningGuy</dc:creator>
      <dc:date>2024-01-17T22:08:41Z</dc:date>
    </item>
    <item>
      <title>Re: Fix JSON format by replacing single quote and put into new field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Fix-JSON-format-by-replacing-single-quote-and-put-into-new-field/m-p/674581#M230903</link>
      <description>&lt;P&gt;Maybe something like this?&lt;BR /&gt;&lt;BR /&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;&amp;lt;base_search&amp;gt;
    | eval
        employee_data=replace(replace(employee_data, "\'", "\""), "None", "\"None\"")
    | spath input=employee_data&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Testing on my local instance looks like it worked out.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dtburrows3_0-1705532665943.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/28981i16B79358D20C99FD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="dtburrows3_0-1705532665943.png" alt="dtburrows3_0-1705532665943.png" /&gt;&lt;/span&gt;&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="dtburrows3_2-1705532793823.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/28983iC9AC4FBCDC391D9D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="dtburrows3_2-1705532793823.png" alt="dtburrows3_2-1705532793823.png" /&gt;&lt;/span&gt;&lt;/P&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, 17 Jan 2024 23:06:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Fix-JSON-format-by-replacing-single-quote-and-put-into-new-field/m-p/674581#M230903</guid>
      <dc:creator>dtburrows3</dc:creator>
      <dc:date>2024-01-17T23:06:42Z</dc:date>
    </item>
    <item>
      <title>Re: Fix JSON format by replacing single quote and put into new field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Fix-JSON-format-by-replacing-single-quote-and-put-into-new-field/m-p/674585#M230904</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;Which part of your search that put the into a new field "formatted_data"?&lt;BR /&gt;I don't see "formatted_data" in the search.&lt;BR /&gt;Can you paste the whole search including how you put simulated data?&lt;BR /&gt;&lt;BR /&gt;Thank you for your help.&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jan 2024 23:21:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Fix-JSON-format-by-replacing-single-quote-and-put-into-new-field/m-p/674585#M230904</guid>
      <dc:creator>LearningGuy</dc:creator>
      <dc:date>2024-01-17T23:21:07Z</dc:date>
    </item>
    <item>
      <title>Re: Fix JSON format by replacing single quote and put into new field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Fix-JSON-format-by-replacing-single-quote-and-put-into-new-field/m-p/674586#M230905</link>
      <description>&lt;P&gt;More of just an additional screenshot for context and a fieldname with a description of the eval that was done to it... but I see that is has caused some confusion.&lt;BR /&gt;&lt;BR /&gt;Here is full search of the local emulation.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
    | eval
        employee_data="[{'company':'company A','name': 'employee A1','position': None}, {'company': 'company A','name': 'employee A2','position': None}]"
    | append
        [
            | makeresults
                | eval
                    employee_data="[{'company':'company B','name': 'employee B1','position': None}, {'company': 'company B','name': 'employee B2','position': None}]"
            ]
    | append
        [
            | makeresults
                | eval
                    employee_data="[{'company':'company C','name': 'employee C1','position': None}, {'company': 'company C','name': 'employee C2','position': None}]"
            ]
    | eval
        formatted_data=replace(replace(employee_data, "\'", "\""), "None", "\"None\"")
    | spath input=formatted_data&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 17 Jan 2024 23:24:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Fix-JSON-format-by-replacing-single-quote-and-put-into-new-field/m-p/674586#M230905</guid>
      <dc:creator>dtburrows3</dc:creator>
      <dc:date>2024-01-17T23:24:44Z</dc:date>
    </item>
    <item>
      <title>Re: Fix JSON format by replacing single quote and put into new field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Fix-JSON-format-by-replacing-single-quote-and-put-into-new-field/m-p/674689#M230943</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;&lt;BR /&gt;I tested your solution and it worked.&amp;nbsp; &amp;nbsp; Thank you for your help.&amp;nbsp;&lt;BR /&gt;1) if I put eval on employee_data, will it &lt;STRONG&gt;change the original data&lt;/STRONG&gt;?&lt;BR /&gt;2) I apply the solution on the real data and I got the following error. &lt;STRONG&gt;How do I fix this without increasing memory limit?&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;command.mvexpand: output will be truncated at 1000 results due to excessive memory usage. Memory threshold of 500MB as configured in limits.conf / [mvexpand] / max_mem_usage_mb has been reached&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jan 2024 15:25:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Fix-JSON-format-by-replacing-single-quote-and-put-into-new-field/m-p/674689#M230943</guid>
      <dc:creator>LearningGuy</dc:creator>
      <dc:date>2024-01-18T15:25:06Z</dc:date>
    </item>
    <item>
      <title>Re: Fix JSON format by replacing single quote and put into new field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Fix-JSON-format-by-replacing-single-quote-and-put-into-new-field/m-p/674693#M230947</link>
      <description>&lt;P&gt;It sounds like the original data has too many lines/events.&amp;nbsp; You may want to implement EventBreaker or LineBreak in your props.conf on the ingest before you need to apply any search time eval or mvexpand.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jan 2024 15:40:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Fix-JSON-format-by-replacing-single-quote-and-put-into-new-field/m-p/674693#M230947</guid>
      <dc:creator>dural_yyz</dc:creator>
      <dc:date>2024-01-18T15:40:12Z</dc:date>
    </item>
  </channel>
</rss>

