Skip to content
JSON in your Bash scripts
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore Fixes #1:infinite loop on dicts, #16:consumed backtick Jan 31, 2012
Makefile Added a Makefile for test and install Jul 1, 2012 Updating readme with a disclosure Jun 26, 2016


TickTick enables you to put JSON in bash scripts. Yes, just encapsulate them with two back-ticks.

Note: This is just a fun hack. You may want to consider using mature languages like Ruby or Perl to solve actual real life problems. Oh who am I kidding, I use whitespace and brainfuck every day.


Proper usage (if there is such a thing), is to place the following line right after the "shbang" at the top of your script. For instance:

# This is really important stuff. Don't edit it!


See how that's near the tippity-top? That's where it's supposed to go. If you put it lower, all bets are off. :-(



A few array manipulation runtime directives are supported:

  • [] (as new Array)
    ``arr = ["foo"]``
  • [] (to index)
    echo ``arr[0]``
  • length
    arr_len=``arr.length()``; echo ${arr_len}
  • push
  • pop
    echo ``arr.pop()``
  • shift
    echo ``arr.shift()``
  • delete
    echo ``key.value.delete()``
  • items
    for x in ``arr.items()``; do echo "${x}"; done


  • These feature do not preclude having variables by those names. You can have key.delete = 1 and then key.delete.delete()
  • Since TickTick is a Bash-emitting transpiler, things that don't work in bash (such as modifying in-shell variables in double quotes) don't work in TickTick.


  • {} (as new Object)
    ``obj = { "foo": "bar", "baz": "qux" }``
  • [] (to index)
    echo ``obj["foo"]``
  • . (to index)
    echo ``obj.baz``


tickParse - parse things inline

  • Inline parsing: You can parse a file in with the tickParse routine (see the example).

tickVars - see the currently defined variables

  • Show all variables: You can see the current values defined in the TickTick world with the tickVars routine.

__tick_var_debug - See the interim bash code

  • Dry run (display compiled code): TickTick is a mini-compiler that emits bash. If you declare extern __tick_var_debug=1 at the top of your code, then the code will not run but instead print what it would have run.

Bash variables ($) in JSON

Along with assignment operations1, and Javascript like indexing into objects and arrays.

Additionally, bash variables (eg., "$name") are preserved in the TickTick blocks. For instance, once could do

`` Var.Data = [] ``
`` Var.Data.push($key) ``
bashvar=`` Var.Data.pop() ``

1Although Javascript supports $ prefixed variables, this does not.


Inline Parsing




  people = {
    "HR" : [
    "Sales": {
      "Gale": { "profits" : 1000 },
      "Harry": { "profits" : 500 }

function printEmployees() {
  echo "  The ``people.Engineering.length()`` Employees listed are:"

  for employee in ``people.Engineering.items()``; do
    printf "    - %s\n" ${!employee}


echo Base Assignment
`` people.Engineering = [ "Darren", "Edith", "Frank" ] ``

echo Pushed a new element by variable, $newPerson onto the array
`` people.Engineering.push($newPerson) ``

echo Shifted the first element off: `` people.Engineering.shift() ``

echo Popped the last value off: `` people.Engineering.pop() ``

echo Indexing an array, doing variable assignments

echo $person0 ``people.HR[1]``

Using a File or cURL

. ../

# File
DATA=`cat data.json`
# cURL

tickParse "$DATA"

echo ``pathname``
echo ``headers["user-agent"]``

Mailing List

Join it over here.


This software is available under the following licenses:

  • MIT
  • Apache 2

Parts of this work are derived from, which is also available under the aforementioned licenses.

You can’t perform that action at this time.