Giter Site home page Giter Site logo

markandrewj / json Goto Github PK

View Code? Open in Web Editor NEW

This project forked from trentm/json

0.0 3.0 0.0 2.15 MB

A "json" command for massaging JSON on your Unix command line.

Home Page: http://trentm.com/json

License: Other

Makefile 5.16% JavaScript 90.53% Python 4.30%

json's Introduction

json is a fast CLI tool for working with JSON. It is a single-file node.js script with no external deps (other than node.js itself). A quick taste:

$ echo '{"foo":"bar"}' | json
{
  "foo": "bar"
}

$ echo '{"foo":"bar"}' | json foo
bar

$ echo '{"fred":{"age":42}}' | json fred.age    # '.' for property access
42

$ echo '{"age":10}' | json -e 'this.age++'
{
  "age": 11
}

# `json -ga` (g == group, a == array) for streaming mode
$ echo '{"latency":32,"req":"POST /widgets"}
{"latency":10,"req":"GET /ping"}
' | json -gac 'this.latency > 10' req
POST /widgets

Features:

  • pretty-printing JSON
  • natural syntax (like JS code) for extracting particular values
  • get details on JSON syntax errors (handy for config files)
  • filter input JSON (see -e and -c options)
  • fast stream processing
  • JSON validation
  • in-place file editing

See http://trentm.com/json for full docs and examples as a man page.

Follow @trentmick for updates to json.

Installation

  1. Get node.

  2. npm install -g json

    Note: This used to be called 'jsontool' in the npm registry, but as of version 8.0.0 it has taken over the 'json' name. See npm Package Name below.

OR manually:

  1. Get the 'json' script and put it on your PATH somewhere (it is a single file with no external dependencies). For example:

     cd ~/bin
     curl -L https://github.com/trentm/json/raw/master/lib/json.js > json
     chmod 755 json
    

You should now have "json" on your PATH:

$ json --version
json 9.0.0

WARNING for Ubuntu/Debian users: There is a current bug in Debian stable such that "apt-get install nodejs" installed a nodejs binary instead of a node binary. You'll either need to create a symlink for node, change the json command's shebang line to "#!/usr/bin/env nodejs" or use chrislea's PPA as discussed on issue #56.

Test suite

make test

You can also limit (somewhat) which tests are run with the TEST_ONLY envvar, e.g.:

cd test && TEST_ONLY=executable nodeunit test.js

I test against node 0.4 (less so now), 0.6, 0.8, and 0.10.

License

MIT (see the fine LICENSE.txt file).

Module Usage

Since v1.3.1 you can use "json" as a node.js module:

var json = require('json');

However, so far the module API isn't that useful and the CLI is the primary focus.

npm Package Name

Once upon a time, json was a different thing (see zpoley's json-command here), and this module was called jsontool in npm. As of version 8.0.0 of this module, npm install json means this tool.

If you see documentation referring to jsontool, it is most likely referring to this module.

Alternatives you might prefer

json's People

Contributors

trentm avatar fkuo avatar isaacs avatar pijewski avatar felixrabe avatar vi avatar yaniv-aknin avatar

Watchers

Mark Jackson avatar James Cloos avatar  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.