Coder Social home page Coder Social logo

json.awk's Introduction

JSON.awk

A practical JSON parser written in awk.

Quick Start

This software is based on JSON.sh, a pipeable JSON parser written in Bash, retrieved on 2013-03-13 and herein ported to awk. JSON.awk is a self-contained script with no external dependencies.

Features

  • JSON.sh compatible output format (as of 2013-03-13)
  • Can parse one or multiple input files in a single invocation
  • Captures invalid JSON input and processes it upon exiting
  • Written for awk, does not require gawk extensions
  • Does not depend on external programs
  • Choice of MIT or Apache 2 license

Setup

Just drop the file JSON.awk in your project folder and run it as an awk script. You need to specify input arguments in a slightly unconventional way, so pay attention to usage notes.

Usage

JSON.awk takes no input arguments on the command-line. Instead it reads a list of input filenames from stdin, one filename per line. An empty line marks the end of the list:

echo -e "file1\nfile2\n" | awk -f JSON.awk

Of course you can use redirection instead of piping:

echo -e "file1\nfile2\n" > list && awk -f JSON.awk < list

To pass JSON from stdin you can use:

{ echo -; echo; cat; } | awk -f JSON.awk

Real-Life Examples

  • KindleLauncher a.k.a. KUAL, an application launcher for the Kindle e-ink models, uses JSON.awk to parse menu descriptions.

Application Notes

Within a single invocation JSON.awk processes each input file separately from all other input files. This means that it resets internal data structures upon reading each input file. However your application may need to process all files as a single lump. To enable such mode please read the comments in function reset() in the source code.

License

This software is available under the following licenses:

  • MIT
  • Apache 2

Credits

Without JSON.sh this software would not exist. It owes JSON.sh its entire tokenizer and parser logic.

json.awk's People

Contributors

step- avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.