{"id":13587200,"url":"https://github.com/dbohdan/jsonwatch","last_synced_at":"2025-04-06T13:11:44.756Z","repository":{"id":15105721,"uuid":"17832542","full_name":"dbohdan/jsonwatch","owner":"dbohdan","description":"Track changes in JSON data from the command line","archived":false,"fork":false,"pushed_at":"2024-05-28T16:32:26.000Z","size":116,"stargazers_count":166,"open_issues_count":0,"forks_count":5,"subscribers_count":11,"default_branch":"master","last_synced_at":"2024-10-12T13:14:07.578Z","etag":null,"topics":["change-report","cli","command-line-tool","json","monitor-changes","rust","watch"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/jsonwatch","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dbohdan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-03-17T15:20:26.000Z","updated_at":"2024-10-11T13:16:13.000Z","dependencies_parsed_at":"2024-05-10T11:47:21.268Z","dependency_job_id":"a533618f-d5ff-426d-a988-046953f25d3f","html_url":"https://github.com/dbohdan/jsonwatch","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dbohdan%2Fjsonwatch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dbohdan%2Fjsonwatch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dbohdan%2Fjsonwatch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dbohdan%2Fjsonwatch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dbohdan","download_url":"https://codeload.github.com/dbohdan/jsonwatch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247485290,"owners_count":20946398,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["change-report","cli","command-line-tool","json","monitor-changes","rust","watch"],"created_at":"2024-08-01T15:06:05.577Z","updated_at":"2025-04-06T13:11:44.737Z","avatar_url":"https://github.com/dbohdan.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"# jsonwatch — like `watch -d`, but for JSON\n\njsonwatch is a command-line utility that lets you track changes in JSON data delivered by a command or a web (HTTP/HTTPS) API.\njsonwatch requests data from the source repeatedly at a set interval.\nIt displays the differences when the data changes.\nIt is similar but not identical to how [watch(1)](https://manpages.debian.org/stable/procps/watch.1.en.html) with the `-d` switch works for plain text.\n\njsonwatch has been tested on Debian 12, Ubuntu 24.04, macOS 14, and Windows 10 and Server 2022.\n\nThe two previous versions of jsonwatch are preserved in the branch\n[`python`](https://github.com/dbohdan/jsonwatch/tree/python)\nand\n[`haskell`](https://github.com/dbohdan/jsonwatch/tree/haskell).\n\n## Installation\n\nPrebuilt binaries are available for Linux (x86_64) and Windows (x86).\nBinaries are attached to releases on the\n[\"Releases\"](https://github.com/dbohdan/jsonwatch/releases)\npage.\n\n### Installing with Cargo\n\n```sh\ncargo install jsonwatch\n```\n\n### Building on Debian and Ubuntu\n\nFollow the instructions to build a static Linux binary of jsonwatch from the source code on recent Debian and Ubuntu.\n\n1\\. Install [Rustup](https://rustup.rs/).\n    Through Rustup, add the stable musl libc target for your CPU.\n\n```sh\nrustup target add x86_64-unknown-linux-musl\n```\n\n2\\. Install the build and test dependencies.\n\n```sh\nsudo apt install build-essential expect musl-tools\ncargo install just\n```\n\n3\\. Clone this repository.\n    Build the binary.\n\n```sh\ngit clone https://github.com/dbohdan/jsonwatch\ncd jsonwatch\njust test\njust release-linux\n```\n\n### Cross-compiling for Windows\n\nFollow the instructions to build a 32-bit Windows binary of jsonwatch on recent Debian and Ubuntu.\n\n1\\. Install [Rustup](https://rustup.rs/).\n    Through Rustup, add the i686 GNU ABI Windows target.\n\n```sh\nrustup target add i686-pc-windows-gnu\n```\n\n2\\. Install the build dependencies.\n\n```sh\nsudo apt install build-essential mingw-w64\ncargo install just\n```\n\n3\\. Configure Cargo for cross-compilation.\n    Add the following to `~/.cargo/config`.\n\n```toml\n[target.i686-pc-windows-gnu]\nlinker = \"/usr/bin/i686-w64-mingw32-gcc\"\n```\n\n4\\. Clone this repository.\n    Build the binary.\n\n```sh\ngit clone https://github.com/dbohdan/jsonwatch\ncd jsonwatch\njust release-windows\n```\n\n## Usage\n\nYou must run jsonwatch with a subcommand.\n\njsonwatch ignores data that isn't valid JSON.\n\n### General options\n\n```none\nTrack changes in JSON data\n\nUsage: jsonwatch [OPTIONS] \u003cCOMMAND\u003e\n\nCommands:\n  cmd   Execute a command and track changes in the JSON output\n  url   Fetch a URL and track changes in the JSON data\n  help  Print this message or the help of the given subcommand(s)\n\nOptions:\n  -D, --no-date             Don't print date and time for each diff\n  -I, --no-initial-values   Don't print initial JSON values\n  -d, --debug               Print raw data to standard error with a timestamp\n  -n, --interval \u003cseconds\u003e  Polling interval in seconds [default: 1]\n  -h, --help                Print help\n  -V, --version             Print version\n```\n\n### `cmd` subcommand\n\nYou can use `c`, `cmd`, or `command` as the name of the subcommand.\n\n```none\nExecute a command and track changes in the JSON output\n\nUsage: jsonwatch cmd \u003ccommand\u003e [arg]...\n\nArguments:\n  \u003ccommand\u003e  Command to execute\n  [arg]...   Arguments to the command\n\nOptions:\n  -h, --help  Print help\n```\n\n### `url` subcommand\n\nYou can use `u` or `url` as the name of the subcommand.\n\n```none\nFetch a URL and track changes in the JSON data\n\nUsage: jsonwatch url [OPTIONS] \u003curl\u003e\n\nArguments:\n  \u003curl\u003e  URL to fetch\n\nOptions:\n  -A, --user-agent \u003cuser-agent\u003e  Custom User-Agent string [default: curl/7.58.0]\n  -H, --header \u003cheader\u003e          Custom headers in the format \"X-Foo: bar\"\n  -h, --help                     Print help\n```\n\n## Use examples\n\n### Command\n\n#### Testing jsonwatch\n\nThis example uses the POSIX shell to generate random JSON test data.\n\n```none\n$ jsonwatch -n 1 cmd sh -c \"echo '{ \\\"filename\\\": \\\"'\\$(mktemp -u)'\\\"}'\"\n\n{\n  \"filename\": \"/tmp/tmp.dh3Y7LJTaK\"\n}\n2020-01-19T18:52:19+0000 .filename: \"/tmp/tmp.dh3Y7LJTaK\" -\u003e \"/tmp/tmp.i4s56VENEJ\"\n2020-01-19T18:52:20+0000 .filename: \"/tmp/tmp.i4s56VENEJ\" -\u003e \"/tmp/tmp.zzMUSn45Fc\"\n2020-01-19T18:52:21+0000 .filename: \"/tmp/tmp.zzMUSn45Fc\" -\u003e \"/tmp/tmp.Jj1cKt6VLr\"\n2020-01-19T18:52:22+0000 .filename: \"/tmp/tmp.Jj1cKt6VLr\" -\u003e \"/tmp/tmp.1LGk4ok8O2\"\n2020-01-19T18:52:23+0000 .filename: \"/tmp/tmp.1LGk4ok8O2\" -\u003e \"/tmp/tmp.wWulyho8Qj\"\n```\n\n#### Docker\n\nThe command in this example tracks Docker process information when you have a single running container.\n\n```none\n$ jsonwatch command docker ps -a \"--format={{json .}}\"\n\n2020-01-19T18:57:20+0000\n    + .Command: \"\\\"bash\\\"\"\n    + .CreatedAt: \"2020-01-19 18:57:20 +0000 UTC\"\n    + .ID: \"dce7fb2194ed\"\n    + .Image: \"i386/ubuntu:latest\"\n    + .Labels: \"\"\n    + .LocalVolumes: \"0\"\n    + .Mounts: \"\"\n    + .Names: \"dreamy_edison\"\n    + .Networks: \"bridge\"\n    + .Ports: \"\"\n    + .RunningFor: \"Less than a second ago\"\n    + .Size: \"0B\"\n    + .Status: \"Created\"\n2020-01-19T18:57:21+0000 .RunningFor: \"Less than a second ago\" -\u003e \"1 second ago\"\n2020-01-19T18:57:23+0000\n    .RunningFor: \"1 second ago\" -\u003e \"3 seconds ago\"\n    .Status: \"Created\" -\u003e \"Up 1 second\"\n2020-01-19T18:57:24+0000\n    .RunningFor: \"3 seconds ago\" -\u003e \"4 seconds ago\"\n    .Status: \"Up 1 second\" -\u003e \"Up 2 seconds\"\n2020-01-19T18:57:25+0000\n    .RunningFor: \"4 seconds ago\" -\u003e \"5 seconds ago\"\n    .Status: \"Up 2 seconds\" -\u003e \"Up 3 seconds\"\n```\n\nFor multiple running containers, you will need a more complex jsonwatch command.\nThe command needs to transform the [JSON Lines](https://jsonlines.org/) output into a single JSON document.\nFor example, it can be the following command with the POSIX shell and [jq](https://en.wikipedia.org/wiki/Jq_(programming_language)):\n\n```shell\njsonwatch -I cmd sh -c 'docker ps -a \"--format={{json .}}\" | jq -s .'\n```\n\n#### `cmd.exe` on Windows\n\nThis example is a simple test on Windows.\nWe start watching the output of a `cmd.exe` command, then manually edit the file the command prints and are shown the changes.\n\n```none\n\u003e jsonwatch command cmd.exe /c \"type tests\\weather1.json\"\n\n{\n  \"clouds\": {\n    \"all\": 92\n  },\n  \"name\": \"Kiev\",\n  \"coord\": {\n    \"lat\": 50.43,\n    \"lon\": 30.52\n  },\n  \"sys\": {\n    \"country\": \"UA\",\n    \"message\": 0.0051,\n    \"sunset\": 1394985874,\n    \"sunrise\": 1394942901\n  },\n  \"weather\": [\n    {\n      \"main\": \"Snow\",\n      \"id\": 612,\n      \"icon\": \"13d\",\n      \"description\": \"light shower sleet\"\n    },\n    {\n      \"main\": \"Rain\",\n      \"id\": 520,\n      \"icon\": \"09d\",\n      \"description\": \"light intensity shower rain\"\n    }\n  ],\n  \"rain\": {\n    \"3h\": 2\n  },\n  \"base\": \"cmc stations\",\n  \"dt\": 1394979003,\n  \"main\": {\n    \"pressure\": 974.8229,\n    \"humidity\": 91,\n    \"temp_max\": 277.45,\n    \"temp\": 276.45,\n    \"temp_min\": 276.15\n  },\n  \"id\": 703448,\n  \"wind\": {\n    \"speed\": 10.27,\n    \"deg\": 245.507\n  },\n  \"cod\": 200\n}\n2020-01-19T18:51:04+0000 + .test: true\n2020-01-19T18:51:10+0000 .test: true -\u003e false\n2020-01-19T18:51:23+0000 - .test: false\n```\n\n### URL\n\n#### Weather tracking\n\nThe API in this example no longer works without a key.\n\n```none\n$ jsonwatch --no-initial-values -n 300 url 'http://api.openweathermap.org/data/2.5/weather?q=Kiev,ua'\n\n2014-03-17T23:06:19.073790\n    + .rain.1h: 0.76\n    - .rain.3h: 0.5\n    .dt: 1395086402 -\u003e 1395089402\n    .main.temp: 279.07 -\u003e 278.66\n    .main.temp_max: 279.82 -\u003e 280.15\n    .main.temp_min: 277.95 -\u003e 276.05\n    .sys.message: 0.0353 -\u003e 0.0083\n```\n\n#### Geolocation\n\nTry this on a mobile device.\n\n```none\n$ jsonwatch -I -n 300 u https://ipinfo.io/\n```\n\n## License\n\njsonwatch is distributed under the MIT license.\nSee the file [`LICENSE`](LICENSE) for details.\n[Wapp](tests/vendor/wapp/wapp.tcl) is copyright (c) 2017 D. Richard Hipp and is distributed under the Simplified BSD License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdbohdan%2Fjsonwatch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdbohdan%2Fjsonwatch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdbohdan%2Fjsonwatch/lists"}