{"id":15032107,"url":"https://github.com/scnewma/jset","last_synced_at":"2025-04-10T00:23:00.064Z","repository":{"id":62441356,"uuid":"410698281","full_name":"scnewma/jset","owner":"scnewma","description":"a command-line tool for performing set operations on a list of json files","archived":false,"fork":false,"pushed_at":"2021-09-27T01:01:15.000Z","size":13,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-01T23:11:28.425Z","etag":null,"topics":["json","rust-language","sets"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/scnewma.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}},"created_at":"2021-09-27T00:49:25.000Z","updated_at":"2023-06-19T16:14:39.000Z","dependencies_parsed_at":"2022-11-01T21:53:46.994Z","dependency_job_id":null,"html_url":"https://github.com/scnewma/jset","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scnewma%2Fjset","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scnewma%2Fjset/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scnewma%2Fjset/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scnewma%2Fjset/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/scnewma","download_url":"https://codeload.github.com/scnewma/jset/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248132304,"owners_count":21053021,"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":["json","rust-language","sets"],"created_at":"2024-09-24T20:17:21.161Z","updated_at":"2025-04-10T00:23:00.016Z","avatar_url":"https://github.com/scnewma.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jset\njset is a command-line tool for performing set operations on a list of json files\n\n## Installation\n\nCurrently you will need a [Rust development environment setup](https://www.rust-lang.org/tools/install) to install `jset`.\n\n```\ncargo install jset\n```\n\n## Whirlwind Tour\n\n`jset` requires at least two json files to work with, but can work with any number of json files. The basic structure of a jset command is as follows (where `FILE` is a path to a JSON file):\n\n```\njset \u003coperation\u003e [flags] FILE FILE [...FILE]\n```\n\nBy default all output is pretty printed, but this can be disabled using the `-c` flag. This will be done in all examples below to make them more readable.\n\n### Union\n`jset union` computes the set union between two or more json files.\n\n#### Objects\n\nFields are recursively merged together.\n```\n$ jset union -c \u003c(echo '{\"a\":{\"b\": \"c\"}}') \u003c(echo '{\"a\":{\"c\": \"d\"},\"e\":\"f\"}')\n{\"a\":{\"b\":\"c\",\"c\":\"d\"},\"e\":\"f\"}\n```\n\nWhen conflicting keys exist, later files take precedence over earlier files.\n```\n$ jset union -c \u003c(echo '{\"a\":\"b\"}') \u003c(echo '{\"a\":\"c\"}')\n{\"a\":\"c\"}\n```\n\n#### Arrays\nElements from each array are concatenated together.\n```\n$ jset union -c \u003c(echo '[\"a\",\"b\",\"c\"]') \u003c(echo '[\"d\",\"e\",\"f\"]')\n[\"a\",\"b\",\"c\",\"d\",\"e\",\"f\"]\n```\n\nDuplicate elements from later lists are ignored in final result.\n```\n$ jset union -c \u003c(echo '[\"a\",\"b\",\"c\"]') \u003c(echo '[\"b\",\"c\",\"d\"]')\n[\"a\",\"b\",\"c\",\"d\"]\n```\n\n#### Primitives (numbers, bools, strings, null)\n\nPrimitive values union successfully if the values are identical, otherwise no union is found and the program execution fails.\n```\n$ jset union -c \u003c(echo '\"a\"') \u003c(echo '\"a\"')\n\"a\"\n```\n\n```\n$ jset union -c \u003c(echo '\"a\"') \u003c(echo '\"b\"')\n$ echo $?\n1\n```\n\n### Intersect\n`jset intersect` computes the set intersection between two or more json files.\n\n#### Objects\n\nNew object is returned with fields that exist in all files, recursively.\n```\n$ jset intersect -c \u003c(echo '{\"a\":{\"b\":\"c\",\"g\":\"i\"}}') \u003c(echo '{\"a\":{\"b\":\"c\",\"g\":\"h\"},\"e\":\"f\"}')\n{\"a\":{\"b\":\"c\"}}\n```\n\n#### Arrays\nElements from first file are retained as long as they exist in all subsequent files.\n```\n$ jset intersect -c \u003c(echo '[\"a\",\"b\",\"c\"]') \u003c(echo '[\"a\",\"d\",\"e\"]')\n[\"a\"]\n```\n\n#### Primitives (numbers, bools, strings, null)\n\nPrimitive values intersect successfully if the values are identical, otherwise no intersection is found and the program execution fails.\n```\n$ jset intersect -c \u003c(echo '\"a\"') \u003c(echo '\"a\"')\n\"a\"\n```\n\n```\n$ jset intersect -c \u003c(echo '\"a\"') \u003c(echo '\"b\"')\n$ echo $?\n1\n```\n\n### Difference\n`jset difference` (alias: `jset diff`) computes the set difference between two or more json files. This is done iteratively with the 2nd file being subtracted from the first, the 3rd being subtracted from the difference between the 1st and 2nd and so on.\n\nAn example with four files would be processed in the following way:\n```\n((1-2)-3)-4\n\n# or more simply\n1-2-3-4\n```\n\n#### Objects\n\nThe returned object is the first file with the second file subtracted from it, recursively. Uknown fields in the subsequent files are ignored.\n```\n$ jset diff -c \u003c(echo '{\"a\":{\"b\":\"c\",\"g\":\"i\"}}') \u003c(echo '{\"a\":{\"b\":\"c\",\"g\":\"h\"},\"e\":\"f\"}')\n{\"a\":{\"g\":\"i\"}}\n```\n\n#### Arrays\nElements from first file are removed if they appear in any subsequent files.\n```\n$ jset diff -c \u003c(echo '[\"a\",\"b\",\"c\"]') \u003c(echo '[\"a\",\"d\",\"e\"]')\n[\"b\",\"c\"]\n```\n\n#### Primitives (numbers, bools, strings, null)\n\nPerforming set differences on primitive values will return the first value when all other values are not equal, otherwise it will fail.\n\n\u003e Note: I didn't have any use-case for doing set differences on primitives so I don't know if this is really useful behavior. :shrug:\n\n```\n$ jset diff -c \u003c(echo '\"a\"') \u003c(echo '\"a\"')\n$ echo $?\n1\n```\n\n```\n$ jset diff -c \u003c(echo '\"a\"') \u003c(echo '\"b\"')\n\"a\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscnewma%2Fjset","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscnewma%2Fjset","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscnewma%2Fjset/lists"}