Jo – a shell divulge to develop JSON

Jo – a shell divulge to develop JSON

I received bored with making an try to win shell scripts to execute superior JSON. You’ve seemingly viewed something esteem this sooner than:

echo '{"identify":"Jane"}'

It will get merrier if a fragment contains an ambiance variable: start double, end single, add variable, start single, blergh.

A here! script will enact it as will a a printf(1), but neither noteworthy enhance legibility, and if strings comprise quotes, it turns into nearly very no longer at risk of carry out a script execute JSON.

printf '{"identify": "%s"}n' "Jane"


Enter jo:

$ jo identify=Jane
{"identify": "Jane"}

The foundation took place to me late at night, and I don’t know why this has taken so prolonged to happen:

$ jo time=$(date +%s) dir=$HOME
{"time": 1457195712,"dir": "/Users/jpm"}

Bam! Jo tries to be involving about kinds and knows null, booleans, strings and numbers. It does arrays, and it pretty-prints on query:

$ jo -p -a spring summer season wintry climate

Impressed by a observation on HN, I added another hack: if a key’s price begins with a gap brace ({) or a bracket ([]) we try to decode JSON from it; this enables jo to add objects or arrays (use -a!) to itself. Look:

$ jo -p identify=JP object=$(jo fruit=Orange point=$(jo x=10 y=20) quantity=17) sunday=unfounded
   "identify": "JP",
   "object": {
      "fruit": "Orange",
      "point": {
         "x": 10,
         "y": 20
      "quantity": 17
   "sunday": unfounded

jo also supports nested kinds natively:

$ jo -p quantity=17 scurry=perfect geo[lon]=88 geo[cc]=ES point[]=1 point[]=2 geo[lat]=123.45
   "quantity": 17,
   "scurry": perfect,
   "geo": {
      "lon": 88,
      "cc": "ES",
      "lat": 123.45
   "point": [

Why did I enact this? I need slightly a few JSON for making an try out OwnTracks, and this perfect appears better in scripts.

$ jo _type=popularity 
   cog=$((RANDOM % 360)) 
   tst=$(date +%s) | mosquitto_pub -t owntracks/jjolie/take a look at -l

A suggestion by Andrew Bibby introduced alongside the doubtless for obtaining JSON ingredient values from recordsdata, so I added @file to read a file (sans traling newline or carriage return) real into a price to boot to something which I use loads, convert binary recordsdata to depraved64, the use of the %file syntax:

$ jo _type=card identify="Vanessa" face=%vanessa.png
{"_type": "card","identify": "Vanessa","face": "iVBORw0KGgoAAA ... QmCC"}

And it has a person page. Streak win it. Jo!


  • Caius Durling supplied a Homebrew faucet for jo, but jo is in Homebrew Formulae now, so brew set up jo.
  • jo has a emblem which it created itself; colors inspired by something Frederic Cambus acknowledged 🙂
  • Shawn Webb added jo to HardenedBSD’s ports.
  • I’ve transformed jo to use autotools; releases shall be printed here.
  • Alessio Sergi has added jo to voidlinux; set up with xbps-set up -Su jo
  • I’ve constructed a Snatch32 binary which you doubtless can win from releases/.
  • Lance Chen has an ArchLinux port of jo.
  • Vincent Bernat has submitted jo to Debian.

NOW WITH OVER +8500 USERS. folks can Be a part of Knowasiak for free. Test in on
Read More



“Simplicity, patience, compassion.
These three are your greatest treasures.
Simple in actions and thoughts, you return to the source of being.
Patient with both friends and enemies,
you accord with the way things are.
Compassionate toward yourself,
you reconcile all beings in the world.”
― Lao Tzu, Tao Te Ching

you're currently offline