Get the latest tech news

Parsing JSON in Forty Lines of Awk


A single-function JSON parser for the POSIX shell.

There are well-known tools such as jq that let you correctly parse JSON documents in the shell, but all require an additional dependency. awk is the closest thing to a real programming language that’s available in the POSIX shell, so I thought I’d try to write a basic JSON parser in it. The interface is simple, a single function that accepts a JSON document and a dotted path to a key or array index, and returns the corresponding value.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of lines

lines

Photo of json

json

Photo of awk

awk

Related news:

News photo

FSE meets the FBI

News photo

Morgan Stanley Says Its AI Tool Processed 9 Million Lines of Legacy Code This Year And Saved 280,000 Developer Hours

News photo

Show HN: Moon Phase Algorithms for C, Lua, Awk, JavaScript, etc.