command line JSON editor
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
Godeps Godep Jun 5, 2016
vendor/github.com Godep Jun 5, 2016
.gitignore Initial commit Dec 19, 2015
.travis.yml
LICENSE.txt Added License May 21, 2016
README.md This is what happens when I get bored. Dec 20, 2015
add.go This is what happens when I get bored. Dec 20, 2015
add_test.go This is what happens when I get bored. Dec 20, 2015
del.go This is what happens when I get bored. Dec 20, 2015
del_test.go This is what happens when I get bored. Dec 20, 2015
get.go This is what happens when I get bored. Dec 20, 2015
get_test.go This is what happens when I get bored. Dec 20, 2015
log.go Initial commit Dec 19, 2015
main.go
test.json This is what happens when I get bored. Dec 20, 2015
utils.go This is what happens when I get bored. Dec 20, 2015

README.md

jsed: A JSON Editor

jsed is a small command-line utility to add, remove, and search for data in a JSON structure.

Not to be confused with any other jsed.

Examples

$ echo {} | jsed add object --path foo --value bar -r
{
  "foo": "bar"
}

$ echo {} | jsed add object --path foo --value bar | jsed add array --path bar.baz --value a --value b --value c -r
{
  "bar": {
    "baz": [
      "a",
      "b",
      "c"
    ]
  },
  "foo": "bar"
}

$ echo {} | jsed add object --path foo --value bar | jsed add array --path bar.baz --value a --value b --value c | jsed get --path bar.baz.1
b

$ echo {} | jsed add object --path service \
                            --key name --value redis_master \
                            --key address --value 127.0.0.1 \
                            --key port --value 8000 \
                            --key enableTagOverride --value false \
                            --key checks --value []  \
          | jsed add array --path service.tags --value master --value redis --value mysql \
          | jsed add object --path service.checks --key script --value /usr/local/bin/check_redis.py --key interval --value 10s \
          | jsed add object --path service.checks --key script --value /usr/local/bin/check_mysql.py --key interval --value 10s -r > service.json

$ cat service.json
{
  "service": {
    "address": "127.0.0.1",
    "checks": [
      {
        "interval": "10s",
        "script": "/usr/local/bin/check_redis.py"
      },
      {
        "interval": "10s",
        "script": "/usr/local/bin/check_mysql.py"
      }
    ],
    "enableTagOverride": false,
    "name": "redis_master",
    "port": 8000,
    "tags": [
      "master",
      "redis",
      "mysql"
    ]
  }
}

$ jsed get --file service.json --path service..checks..*..script=/usr/local/bin/check_redis.py --delimiter ..
/usr/local/bin/check_redis.py

$ jsed get --file service.json --path service.checks.* -r
[
  {
    "interval": "10s",
    "script": "/usr/local/bin/check_redis.py
  },
  {
    "interval": "10s",
    "script": "/usr/local/bin/check_mysql.py
  }
]