{"id":14985669,"url":"https://github.com/dvershinin/sde","last_synced_at":"2025-04-11T22:06:38.347Z","repository":{"id":46223895,"uuid":"381793566","full_name":"dvershinin/sde","owner":"dvershinin","description":"Structured data editor for CLI","archived":false,"fork":false,"pushed_at":"2024-05-21T06:56:28.000Z","size":49,"stargazers_count":18,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-02T09:34:57.487Z","etag":null,"topics":["cli","editor","json","sed","utility","yaml","yml"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dvershinin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"community_bridge":null,"github":"dvershinin","issuehunt":null,"ko_fi":null,"liberapay":null,"open_collective":null,"otechie":null,"tidelift":null}},"created_at":"2021-06-30T18:10:10.000Z","updated_at":"2024-12-09T03:07:54.000Z","dependencies_parsed_at":"2024-09-25T00:32:40.234Z","dependency_job_id":null,"html_url":"https://github.com/dvershinin/sde","commit_stats":{"total_commits":49,"total_committers":4,"mean_commits":12.25,"dds":0.5510204081632653,"last_synced_commit":"78167904eca2adc4fec7ece9dbe14a30e9a63332"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dvershinin%2Fsde","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dvershinin%2Fsde/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dvershinin%2Fsde/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dvershinin%2Fsde/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dvershinin","download_url":"https://codeload.github.com/dvershinin/sde/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248145860,"owners_count":21055221,"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":["cli","editor","json","sed","utility","yaml","yml"],"created_at":"2024-09-24T14:11:27.562Z","updated_at":"2025-04-11T22:06:38.294Z","avatar_url":"https://github.com/dvershinin.png","language":"Python","funding_links":["https://github.com/sponsors/dvershinin"],"categories":[],"sub_categories":[],"readme":"# sde\n\n[![PyPI version](https://badge.fury.io/py/sde.svg)](https://badge.fury.io/py/sde)\n\n`sde` is not `sed`. It's a structured data editor for CLI.\n\n## Why?\n\nMany people asked for a simple JSON in-place editing and `jq` was the solution:\n\n* [Modify a key-value in a json using jq in-place](https://stackoverflow.com/questions/42716734/modify-a-key-value-in-a-json-using-jq-in-place)\n* [How to modify a key's value in a JSON file from command line](https://stackoverflow.com/questions/43292243/how-to-modify-a-keys-value-in-a-json-file-from-command-line)\n\n```bash\njq '.address = \"abcde\"' test.json|sponge test.json\n```\n    \nDoes this seem readable or elegant to you?\n\nHow about this instead:\n\n```bash\nsde address abcde test.json\n```\n\n`sde` is not a substitute for `jq` or `sed`.\n\nIt allows *simple* in-place JSON/YAML value changes, for *structured* data.\n\n### Sample JSON\n\n```json\n{\n   \"name\":\"John\",\n   \"age\":31,\n   \"city\":\"New York\",\n   \"extra\": {\n       \"gender\": null\n   }\n}\n```\n\n### Sample YAML\n\n```yaml\ndatabase:\n  user: example\n  password: secret\n```\n\n### Modify data\n\n```bash\nsde name Jack data.json\nsde extra.gender male data.json\nsde database.user john data.yml\n```\n\nIt is possible to modify data in arrays using a dotted notation. Let's take another sample:\n\n```json\n{\n    \"users\": [\n        {\n            \"username\": \"foo\", \n            \"enabled\": true\n        },\n        {\n            \"username\": \"bar\", \n            \"enabled\": true\n        }      \n    ],\n}\n```\n\nWe can set the first user's `enabled` property to `false`:\n\n```bash\nsde users.0.enabled false data.json\n```\n\n## Installation for CentOS/RHEL 7, 8 or Amazon Linux 2, or Fedora Linux\n\n```bash\nsudo yum -y install https://extras.getpagespeed.com/release-latest.rpm\nsudo yum -y install sde\n```\n   \n## Installation for other systems\n\nInstalling with `pip` is easiest:\n\n```bash\npip install sde\n```\n\n## Notes\n\n### Quoting in JSON\n\nQuoting is avoided for `null`, `true`, `false`, and numeric values.\nTo ensure that a given value is quoted, use `-s` (or `--string`) option:\n\n```bash\nsde -s key null file.json\n```\n\n### Force-fail on missing keys\n\nIf you must *edit* the file, by ensuring to update only the existing key, use `-e` (`--must-exist`)\noption. The program will exit without adding the key which doesn't exist.\n\n```bash\nsde -e key val file.json\n```\n\n### Force-fail on unchanged file\n\nIf the data is unchanged after running `sde` (values already match), you can force\na failure exit code `2` by passing the `-m` option:\n\n```bash\nsde -m key sameval file.json\n# \u003e exit code 0\nsde -m key sameval file.json\n# \u003e exit code 2\n```\n\n## TODO\n\n### Work with stdin\n\n```bash\necho $json | sde name Jack\n```\n\n### Query simple data\n\n```bash\nsdg name data.json\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdvershinin%2Fsde","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdvershinin%2Fsde","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdvershinin%2Fsde/lists"}