Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Pure-shell JSON parser

branch: master

(#2) Found a way to use POSIX sed(1) after all.

The limitation here is that your JSON can't contain ASCII record separator characters.
latest commit 866b1accac
Richard Crowley authored February 12, 2013
Octocat-spinner-32 bin Formatting. October 25, 2011
Octocat-spinner-32 lib (#2) Found a way to use POSIX sed(1) after all. February 12, 2013
Octocat-spinner-32 tests Fix array handling. September 21, 2012
Octocat-spinner-32 .gitignore Initial import. October 25, 2011
Octocat-spinner-32 LICENSE Initial import. October 25, 2011
Octocat-spinner-32 Makefile Initial import. October 25, 2011
Octocat-spinner-32 README.md (#2) Found a way to use POSIX sed(1) after all. February 12, 2013
Octocat-spinner-32 test.sh Test in a more natural direction. September 21, 2012
README.md

json.sh

Pure-POSIX-shell JSON parser.

Example

Suppose tests/mixed.json contains the following (it does):

{
    "foo": ["bar", "baz"],
    "asdf": {
        "qwerty": 47
    }
}

Running json.sh <"tests/mixed.json" yields:

/foo/0 string bar
/foo/1 string baz
/asdf/qwerty number 47

Installation

make && sudo make install

Usage

From the command-line:

json.sh <"tests/mixed.json"

As a library:

. "lib/json.sh"
json <"tests/mixed.json"

Overriding the default use of / as the key separator:

JSON_SEPARATOR="^" json.sh <"tests/mixed.json"

TODO

  • Whole-ass the half-assed escape sequence and Unicode support.

TODONE

  • Arrays.
  • Booleans.
  • Objects.
  • null.
  • Numbers.
    • Floating-point.
    • Negative.
    • Scientific notation.
  • Strings.
    • Backspace, form feed, newline, and carriage return escapes.
    • Unicode characters specified by their codepoints: \uXXXX.

License

json.sh is BSD-licensed.

Something went wrong with that request. Please try again.