Search
Twitter
Powered by Squarespace
Navigation
« Apple Never Designed the iPad - They Undesigned it (by @baekdal) #opinion | Main | OnLive releases gaming app for tablets, phones - The Washington Post »
Thursday
Dec082011

Imagine a world where Bash supports JSON

01#!/bin/bash
02. ticktick.sh
03 
04``
05  people = {
06    "Writers": [
07      "Rod Serling",
08      "Charles Beaumont",
09      "Richard Matheson"
10    ],
11    "Cast": {
12      "Rod Serling": { "Episodes": 156 },
13      "Martin Landau": { "Episodes": 2 },
14      "William Shatner": { "Episodes": 2 }
15    }
16  }
17``
18 
19function printDirectors() {
20  echo "  The ``people.Directors.length()`` Directors are:"
21 
22  for director in ``people.Directors.items()``; do
23    printf "    - %s\n" ${!director}
24  done
25}
26 
27`` people.Directors = [ "John Brahm", "Douglas Heyes" ] ``
28printDirectors
29 
30newDirector="Lamont Johnson"
31`` people.Directors.push($newDirector) ``
32printDirectors
33 
34echo "Shifted: ``people.Directors.shift()``"
35printDirectors
36 
37echo "Popped: ``people.Directors.pop()``"
38printDirectors

This is awesome!

Posted via email from Ken Swain

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>