<?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 ERROR JsonLineBreaker causes in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/ERROR-JsonLineBreaker-causes/m-p/555508#M92006</link>
    <description>&lt;P&gt;I've run across two major causes of JsonLineBreaker errors.&lt;/P&gt;&lt;P&gt;One cause is character set encoding.&amp;nbsp; It's not enough to want, or intend, to use the UTF-8 character set for writing your JSON or JSONL.&amp;nbsp; You must succeed.&amp;nbsp; Use a UTF-8 validator as the first step in debugging a JsonLineBreaker error.&amp;nbsp; &amp;nbsp;&lt;A href="https://stackoverflow.com/questions/115210/how-to-check-whether-a-file-is-valid-utf-8" target="_blank" rel="noopener"&gt;validation - How to check whether a file is valid UTF-8? - Stack Overflow&lt;/A&gt;&lt;/P&gt;&lt;P&gt;There are some JSON validators out there.&amp;nbsp; Not all of them check the character set encoding.&amp;nbsp; (I should add, JSON can also be written using UTF-16 or UTF-32.)&lt;/P&gt;&lt;P&gt;A second cause of JsonLineBreaker errors is allowing Splunk to read your JSON or JSONL file, while you are writing it.&amp;nbsp; Splunk is very aggressive about reading files while you're still writing to them.&amp;nbsp; If Splunk hits end-of-file on a JSON or JSONL file before it's fully formed, that can cause JsonLineBreaker errors.&amp;nbsp;&lt;/P&gt;&lt;P&gt;There's a simple trick to avoid this problem.&amp;nbsp; Suppose you have Splunk configured to read files ending with .json or .jsonl.&amp;nbsp; Write your JSON to a file with an name Splunk isn't configured to read.&amp;nbsp; Call it c:\temp\my_important_json_file.tmp.&amp;nbsp; When you get finished, close the file.&amp;nbsp; Then rename it from my_important_json_file.tmp to my_important_json_file.json.&lt;/P&gt;&lt;P&gt;There may be smarter ways of handling this race condition between Splunk and your JSON writer, but this one works.&lt;/P&gt;</description>
    <pubDate>Fri, 11 Jun 2021 19:09:11 GMT</pubDate>
    <dc:creator>pgriffith</dc:creator>
    <dc:date>2021-06-11T19:09:11Z</dc:date>
    <item>
      <title>ERROR JsonLineBreaker causes</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/ERROR-JsonLineBreaker-causes/m-p/555508#M92006</link>
      <description>&lt;P&gt;I've run across two major causes of JsonLineBreaker errors.&lt;/P&gt;&lt;P&gt;One cause is character set encoding.&amp;nbsp; It's not enough to want, or intend, to use the UTF-8 character set for writing your JSON or JSONL.&amp;nbsp; You must succeed.&amp;nbsp; Use a UTF-8 validator as the first step in debugging a JsonLineBreaker error.&amp;nbsp; &amp;nbsp;&lt;A href="https://stackoverflow.com/questions/115210/how-to-check-whether-a-file-is-valid-utf-8" target="_blank" rel="noopener"&gt;validation - How to check whether a file is valid UTF-8? - Stack Overflow&lt;/A&gt;&lt;/P&gt;&lt;P&gt;There are some JSON validators out there.&amp;nbsp; Not all of them check the character set encoding.&amp;nbsp; (I should add, JSON can also be written using UTF-16 or UTF-32.)&lt;/P&gt;&lt;P&gt;A second cause of JsonLineBreaker errors is allowing Splunk to read your JSON or JSONL file, while you are writing it.&amp;nbsp; Splunk is very aggressive about reading files while you're still writing to them.&amp;nbsp; If Splunk hits end-of-file on a JSON or JSONL file before it's fully formed, that can cause JsonLineBreaker errors.&amp;nbsp;&lt;/P&gt;&lt;P&gt;There's a simple trick to avoid this problem.&amp;nbsp; Suppose you have Splunk configured to read files ending with .json or .jsonl.&amp;nbsp; Write your JSON to a file with an name Splunk isn't configured to read.&amp;nbsp; Call it c:\temp\my_important_json_file.tmp.&amp;nbsp; When you get finished, close the file.&amp;nbsp; Then rename it from my_important_json_file.tmp to my_important_json_file.json.&lt;/P&gt;&lt;P&gt;There may be smarter ways of handling this race condition between Splunk and your JSON writer, but this one works.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Jun 2021 19:09:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/ERROR-JsonLineBreaker-causes/m-p/555508#M92006</guid>
      <dc:creator>pgriffith</dc:creator>
      <dc:date>2021-06-11T19:09:11Z</dc:date>
    </item>
  </channel>
</rss>

