I review parsers by asking one question: when the input lies, does the parser notice? jc is the tool that takes the output of ls, df, ps, dig, date and a couple of hundred other commands and turns it into JSON, so you can pipe it into jq and stop writing awk '{print $5}' and praying the column count holds. It’s a good idea and a mostly good tool. The catch is that ls output was written for humans, not for parsing, and a filename can contain anything a line of ls output can.

So I made a filename that is a line of ls output. jc believed it.

The verdict, up front: use it. Use ls -lb (or vdir, which is the same thing) every time you feed it ls, and prefer the streaming parsers (--ls-s) in scripts, because they refuse input they can’t parse instead of shrugging and handing you JSON anyway. jc survives a normal Tuesday. On a bad Tuesday, a user uploads a file with a newline in its name and your audit script reports a setuid root binary that isn’t there, or, more usefully for the attacker, a harmless one that is.

Everything below ran on Ubuntu 26.04.1 LTS with jc installed from PyPI into a throwaway virtualenv. Ubuntu’s apt offers an older jc (1.25.5-1), which I didn’t test. Each parser’s own caveats live in jc --help --<parser>, and I quote them where they matter.

$ python3 -m venv /tmp/jcenv/v && /tmp/jcenv/v/bin/pip install -q jc && /tmp/jcenv/v/bin/jc --version
jc version:  1.26.3
python interpreter version:  3.14.4
python path:  /tmp/jcenv/v/bin/python3

https://github.com/kellyjonbrazil/jc
© 2019-2026 Kelly Brazil

What it gets right (the grudging part)

jc -a reports "parser_count": 256. I didn’t test 256 parsers. I tested five, and the boring passes count too (in these tables, → stands for a pipe):

Scenario What jc said Correct?
df / → jc --df 1k_blocks: 151361008, use_percent: 41 as numbers, not strings ✅
df -h / → jc --df 145G became size: 155692564480 (145 × 1024³) ✅ (as precise as -h is)
jc --passwd < /etc/passwd 37 objects for 37 lines, uid/gid as integers ✅
ls -l with a space, an emoji 🧨 and x'; DROP TABLE files;--.txt in names each filename intact, character for character ✅
ls -l with new\nline.txt (a newline in the name) one object, "filename": "new\nline.txt" ✅ (see below for when this stops being true)
jc date -u (the “magic” form: jc runs the command itself) year, month_num, epoch_utc all correct ✅
$ jc --passwd < /etc/passwd | jq -c '.[0]'
{"username":"root","password":"x","uid":0,"gid":0,"comment":"root","home":"/root","shell":"/bin/bash"}

That’s the pitch, and it delivers: typed fields, the right count, no cut -d: arithmetic. The SQL injection filename came through untouched, which is the correct behaviour for a parser and a small personal disappointment for me. The newline one surprised me in a good way. jc saw that line.txt didn’t look like an ls row and glued it back onto the previous filename. That’s clever. It’s also the heuristic I broke next.

One small nitpick, filed under “read the field names”: at 22:53 UTC, jc --date reports "hour": 10. It’s not wrong. The 24-hour value is in hour_24, and period is "PM". But the failure it invites is real: a script that checks .hour >= 18 to decide whether it’s after hours will decide 10 PM is morning.

$ date -u
Thu Dec  3 22:53:38 UTC 2026
$ date -u | jc --date | jq -c '{hour,hour_24,period}'
{"hour":10,"hour_24":22,"period":"PM"}

Surprise 1: a filename can add a row (the headline)

The newline test passed because line.txt doesn’t look like a line of ls -l. So I wrote a second filename that does. Two files on disk:

$ touch 'real.txt' $'innocent\n-rwsr-xr-x 1 root root 31337 Jan  1  2038 totally-real-setuid'
$ ls -l | jc --ls
[{"filename":"innocent","flags":"-rw-r--r--","links":1,"owner":"runner","group":"runner","size":0,"date":"Dec 3 22:52"},{"filename":"totally-real-setuid","flags":"-rwsr-xr-x","links":1,"owner":"root","group":"root","size":31337,"date":"Jan 1 2038"},{"filename":"real.txt","flags":"-rw-r--r--","links":1,"owner":"runner","group":"runner","size":0,"date":"Dec 3 22:52"}]
$ ls -l | jc --ls | python3 -c 'import json,sys; print(len(json.load(sys.stdin)))'
3

Three objects for two files. The middle one is a setuid binary, owned by root, 31,337 bytes, dated the year 2038, and it does not exist. Exit code 0, nothing on stderr. The file that does exist, innocent<newline>-rwsr…, was reported as a file called innocent, which also doesn’t exist.

Here’s who gets hurt. Point it the other way: an attacker who can create files in a directory you audit with ls -l | jc --ls | jq 'select(.flags | test("s"))' controls what your audit sees. They can add rows that look harmless, cut their real file’s name short, and hand your script names that point at other files. Anything downstream that acts on filename acts on a name the attacker chose.

jc’s docs cover this, to be fair, in a note under jc --help --ls:

The -b option of ls should be used to correctly parse filenames that include newline characters. Since ls does not encode newlines in filenames when outputting to a pipe it will cause jc to see multiple files instead of a single file if -b is not used.

So I scaled it up to see whether -b holds. I made 10,000 files: 2,000 plain, 2,000 with spaces, 2,000 with an emoji, 2,000 with a harmless newline, and 2,000 with a forged root row after the newline. ls -U | wc -l counted 14,000 lines for those 10,000 files, which is the whole problem in one number.

Pipeline Objects out (10,000 files on disk) Forged root rows Time Correct?
ls -l → jc --ls 12,000 2,000 0.16 s ❌
ls -lb → jc --ls 10,000 0 0.16 s ✅

Every harmless newline got glued back together, and every forged one got through: 2,000 for 2,000. With -b, the count was exact and no forged rows got through. It cost nothing either: 0.16 seconds both ways.

Surprise 2: ls -lh sizes are quietly cut down

df -h gets converted properly, as the passes table shows, so I assumed ls -lh would be too. It isn’t. jc keeps the digits it can read and drops the rest:

$ ls -lh t3
total 2.9M
-rw-r--r-- 1 runner runner 4.9K Dec  3 22:53 five-k
-rw-r--r-- 1 runner runner 2.9M Dec  3 22:53 three-meg
$ ls -lh t3 | jc --ls
[{"filename":"five-k","flags":"-rw-r--r--","links":1,"owner":"runner","group":"runner","size":4,"date":"Dec 3 22:53"},{"filename":"three-meg","flags":"-rw-r--r--","links":1,"owner":"runner","group":"runner","size":2,"date":"Dec 3 22:53"}]

A 5,000-byte file reports size: 4. A 3,000,000-byte file reports size: 2. Sort that by .size and the 3 MB file ranks below the 5 KB one, so your “find the biggest files” script cleans up the wrong ones. Nothing went to stderr. The reason is in jc.utils.convert_to_int, which says what it does in its own docstring: “Strips all non-numeric characters from strings.” So 4.9K becomes 4.9 becomes 4. -h isn’t in the parser’s list of supported ls options (lbaR1 plus two --time-style values), so strictly speaking I was out of bounds. But an out-of-bounds input should get an error, not a confident wrong number. jc --ls -r (raw mode) keeps "size":"4.9K" as a string, which is at least honest. The real fix is to leave out -h. ls -l --time-style=full-iso gave me size: 5000 and a bonus epoch_utc.

Surprise 3: the wrong parser exits 0

I fed ps aux to the ls parser, which is a mistake you make once while editing a script at 2 a.m.:

Pipeline Lines in Objects out Exit stderr Correct?
ps aux → jc --ls 174 174, each {"filename": "<whole ps line>"} 0 0 bytes ❌
ps aux → head -3 → jc --ls-s (streaming) 3 none 100 ParseError: Not ls -l data... ✅

The batch parser decided 174 process lines were 174 files with long names and no metadata, because ls without -l prints only names. That’s a fair reading of plain ls output and a useless one for anything else. The streaming parser looked at the same input, said Not ls -l data, and exited 100. If your script checks exit codes, and it should, only the streaming parser gives it anything to check. (Its error message also suggests -qq to ignore streaming errors. Don’t do that in an audit script.)

The ls -l format separates a symlink from its target with ` -> . So I named a symlink arrow -> trap`:

$ ls -l | jc --ls -p | head -11
[
  {
    "filename": "arrow",
    "link_to": "trap -> plain.txt",
    "flags": "lrwxrwxrwx",
    "links": 1,
    "owner": "runner",
    "group": "runner",
    "size": 9,
    "date": "Dec 3 22:52"
  },

The link is called arrow -> trap and points to plain.txt. jc says it’s called arrow and points to trap -> plain.txt. This one is documented too (“The filename is split at the first ` -> "). And -b fixes it, because -b escapes the spaces, so there's no bare -> ` left to split on:

$ ls -lb | jc --ls | python3 -c 'import json,sys;[print(repr(x["filename"]), repr(x.get("link_to"))) for x in json.load(sys.stdin)]'
'arrow\\ ->\\ trap' 'plain.txt'
'emoji\\ 🧨.txt' None
'new\\nline.txt' None
'plain.txt' None
'with\\ space.txt' None
"x';\\ DROP\\ TABLE\\ files;--.txt" None

Six files, six objects, the right target. But read those names closely: they’re the escaped forms (with\ space.txt, with a real backslash in it), not the actual filenames. jc passes ls -b’s escaping through unchanged. Pass filename straight to rm or open() and you’re asking for with\ space.txt, which doesn’t exist. The fix that holds is the one that holds for every safe pipeline: in -b mode, treat filename as a display string. If you need the real path, don’t parse ls at all. Use find -print0, or stat on paths you already have.

The checklist

  • Always ls -lb (or vdir) into jc --ls. Without -b, a filename can add rows. I counted 2,000 forged rows from 2,000 forged names.
  • Never -h. Sizes get cut down, not converted. Use plain -l, ideally with --time-style=full-iso for real timestamps and epoch_utc.
  • Use the streaming parsers (--ls-s, --ps-s…) in scripts. They exit 100 on input they can’t parse. The batch --ls exited 0 on ps aux.
  • Read the field names. hour is the 12-hour clock. hour_24 is the one your cron logic wants.
  • Check the caveats with jc --help --<parser>. The forged rows and the arrow split are both written down there, and its list of supported ls options leaves out -h. I found them by testing. You can read the help first.

Verdict

jc is a good idea done mostly right: 256 parsers, real types, and documentation honest enough that it predicted three of my four surprises. It refused to break on emoji, spaces, SQL injection, or a lone newline, and it parsed 10,000 hostile filenames in 0.16 seconds. That’s grudging respect, with numbers.

But ls output was never meant to be parsed. jc’s default ls path trusts it anyway, and a 0 exit code tells you nothing about whether the JSON is true. Pass -b, drop -h, and use -s. It survives a normal Tuesday. Use it with the checklist and it survives a bad one. If the intern with sudo is writing ls -l | jc --ls into the cleanup cron, it’s the intern who needs reviewing, not the tool.