Skip to main content

A CLI tool to edit simple JSON and YAML data files

Project description

sde

PyPI version

sde is not sed. It's a structured data editor for CLI.

Why?

Many people asked for a simple JSON in-place editing and jq was the solution:

jq '.address = "abcde"' test.json|sponge test.json

Does this seem readable or elegant to you?

sde is not a substitue for jq or sed.

It allows simple in-place JSON value changes, for simple data.

{
   "name":"John",
   "age":31,
   "city":"New York",
   "extra": {
       "sex": "male"
   }
}

Modify data

sde name Jack data.json
sde extra.sex female data.json

It is possible to modify data in arrays, e.g.:

{
    "pools": [
        {
            "tls": false, 
            "rig-id": null, 
            "nicehash": false, 
            "url": "pool.hashvault.pro:80", 
            "user": "YOUR_WALLET_ADDRESS", 
            "pass": "x", 
            "enabled": true, 
            "daemon": false, 
            "algo": null, 
            "tls-fingerprint": null, 
            "keepalive": false
        }
    ],
}

Update first pool's pass value to value secret:

sde pools.0.pass secret data.json

Installation for CentOS/RHEL 7, 8 or Amazon Linux 2

sudo yum -y install https://extras.getpagespeed.com/release-latest.rpm
sudo yum -y install sde

Installation for other systems

Installing with pip is easiest:

pip install sde

Notes

Quoting is avoided for null, true, false and numeric values. To ensure that a given value is quoted, use -s (or --string) option:

sde -s key null file.json

If you must edit the file, by ensuring to update only the existing key, use -e (--must-exist) option. The program will exit without adding the key which doesn't exist.

sde -e key val file.json

TODO

Work with stdin

echo $json | sde name Jack

Query simple data

sdg name data.json

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sde-1.0.0.tar.gz (9.2 kB view details)

Uploaded Source

Built Distribution

sde-1.0.0-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file sde-1.0.0.tar.gz.

File metadata

  • Download URL: sde-1.0.0.tar.gz
  • Upload date:
  • Size: 9.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.7.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6

File hashes

Hashes for sde-1.0.0.tar.gz
Algorithm Hash digest
SHA256 a66b3e073030eb693a8a9f9343f98b9b7b22ae690dbf1eb69cbb28c0d516b980
MD5 6a1f7a16c68e93dcf39c59c88c779562
BLAKE2b-256 4158a6165379c368b47f017c806d12a3f0defe55d9d3eecbf8fca1df2d7a1551

See more details on using hashes here.

File details

Details for the file sde-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: sde-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.7.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6

File hashes

Hashes for sde-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0d3ab5dcfca5e52df7320387364e2ae88c181f372a861677e037ba91a155cc4c
MD5 89f9d124d50974043f059f534f1d2e56
BLAKE2b-256 18ffdf04f04691ef3eed9e6c2d3a852e5dc9962a766767954b1901bd623a74c0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page