<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: HY LUO</title>
    <description>The latest articles on DEV Community by HY LUO (@loehy).</description>
    <link>https://dev.to/loehy</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4180335%2F26907a30-db22-47a1-8540-a862724f931a.png</url>
      <title>DEV Community: HY LUO</title>
      <link>https://dev.to/loehy</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/loehy"/>
    <language>en</language>
    <item>
      <title>Repairing one malformed JSONL record with JSONSEEK</title>
      <dc:creator>HY LUO</dc:creator>
      <pubDate>Wed, 14 Oct 2026 12:08:53 +0000</pubDate>
      <link>https://dev.to/loehy/repairing-one-malformed-jsonl-record-with-jsonseek-3b81</link>
      <guid>https://dev.to/loehy/repairing-one-malformed-jsonl-record-with-jsonseek-3b81</guid>
      <description>&lt;p&gt;A JSONL file can be awkward to inspect when one record stops parsing. I built &lt;a href="https://github.com/lo2589/JSONSEEK" rel="noopener noreferrer"&gt;JSONSEEK&lt;/a&gt; to make that workflow more focused: locate the bad line, preview a replacement, then check the file again. Disclosure: I’m the project’s author.&lt;/p&gt;

&lt;p&gt;Here’s a small example you can reproduce:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cat&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; sample.jsonl &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="no"&gt;EOF&lt;/span&gt;&lt;span class="sh"&gt;'
{"id":1,"name":"Ada"}
{"id":2,"name":"unfinished}
&lt;/span&gt;&lt;span class="no"&gt;EOF

&lt;/span&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;jsonseek
jsonseek shape sample.jsonl
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;shape&lt;/code&gt; reports invalid JSONL lines with their line numbers and parser errors. In this example, line 2 is malformed. Once you know what that record should contain, preview the replacement before writing it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;jsonseek replaceline sample.jsonl 2 &lt;span class="s1"&gt;'{"id":2,"name":"Grace"}'&lt;/span&gt; &lt;span class="nt"&gt;--dry-run&lt;/span&gt;
jsonseek replaceline sample.jsonl 2 &lt;span class="s1"&gt;'{"id":2,"name":"Grace"}'&lt;/span&gt; &lt;span class="nt"&gt;--backup&lt;/span&gt;
jsonseek shape sample.jsonl
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The first write command previews the change. The second makes the replacement and requests a &lt;code&gt;.bak&lt;/code&gt; backup. The final &lt;code&gt;shape&lt;/code&gt; call checks the result.&lt;/p&gt;

&lt;p&gt;The same CLI also has path-based commands for inspecting JSON and JSONL (&lt;code&gt;fields&lt;/code&gt;, &lt;code&gt;ls&lt;/code&gt;, and &lt;code&gt;get&lt;/code&gt;), searching with &lt;code&gt;query&lt;/code&gt;, and editing values with commands such as &lt;code&gt;set&lt;/code&gt; and &lt;code&gt;add&lt;/code&gt;. The idea is to inspect the relevant structure or record before changing it.&lt;/p&gt;

&lt;p&gt;JSONSEEK is MIT-licensed. The &lt;a href="https://github.com/lo2589/JSONSEEK" rel="noopener noreferrer"&gt;repository&lt;/a&gt; has the command reference and more examples. If you work with JSONL, how do you usually find and repair a malformed record?&lt;/p&gt;

&lt;p&gt;Tags: #showdev #python #cli #json&lt;/p&gt;

</description>
      <category>showdev</category>
    </item>
  </channel>
</rss>
