Skip to main content

YAML-ish, non parsable format, suitable to diff JSON data

Project description

yamelish

yamelish is a non-parsable YAML-ish output format that was designed as a convenience to diff JSON files.

"non-parsable" means that yamelish was not designed to be parsed by computers. It might actually be parsable with some care and caveats (e.g. no way to distinguish boolean/null values from their string counterparts), but this is not the object of this project.

YAML-ish means that it looks like YAML but is not YAML. Specifically, it looks like YAML, without quotes (except for empty strings), indicators like > or | and advanced features:

postId: 1
id: 1
name: id labore ex et quam laborum
email: Eliseo@gardner.biz
body:
  laudantium enim quasi est quidem magnam voluptate ipsam eos
  tempora quo necessitatibus
  dolor quam autem quasi
  reiciendis et nam sapiente accusantium
examples:
  booleans:
    - True
    - False
  null_value: None
  integer: 4
  float: 4.4
  empty_string: ""
  empty_array: []
  empty_object: {}

yamelish's main limitation is that it offers no way to distinguish non-string values from their textual representation: the "True" string and the true boolean values will both end up as True. Consequently, yamelish remains relevant to spot changing values and structures but not changing types.

Command-line usage

$ yamelish file1.json file2.json

Git usage

Git configuration (typically ~/.config/git/config):

[diff "json_diff"]
    textconv = /path/to/yamelish
; Optional:
[alias]
    showobject = show --ext-diff

Repository's .gitattributes file:

*.json diff=json_diff

Python usage

from yamelish.handlers import handle
yamelish = handle(your_data)[0]
print(yamelish)

Why not ... ?

Why not JSON?

JSON diff is hard to read because of:

  • escaped strings:
    • "this\nis\na\nmultiline\nstring\nand\nthis\nis\npainful"
    • "\"wait, what?\""
  • extra commas when appending to an array:
 {
    "array": [
        "a",
-       "b"
+       "b",
+       "c"
    ]
 }

Why not gron?

Because the gron format reflects array indices, inserting an element into an array makes diff way longer than expected:

 json = {};
 json.array = [];
-json.array[0] = "a";
-json.array[1] = "b";
+json.array[0] = "z";
+json.array[1] = "a";
+json.array[2] = "b";

Why not YAML?

YAML is better but it still clutters the output with quotes, escaped values and/or little things like |-; this is because YAML is a format that is meant to be parsed, so it has to keep this kind of things.

 array:
 - "# this string is double-quoted because otherwise it would be a YAML comment"
-- "# this string is double-quoted because otherwise it would be a YAML comment"
+- this string is no longer double-quoted
 - "# this string is double-quoted because otherwise it would be a YAML comment"

License

yamelish is licensed under WTFPL.

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

yamelish-1.0.0.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

yamelish-1.0.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: yamelish-1.0.0.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.0 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for yamelish-1.0.0.tar.gz
Algorithm Hash digest
SHA256 71dcf55941d7f92e9c41ecf0a0dc309be6482ffa550366432752c8023e079680
MD5 e69dac61a412d01ecd0d5ff99370bc19
BLAKE2b-256 8674cd28f1c9c69df5b696238c373de0ae4d2055e0b67ba3059c75aaf424ca8f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: yamelish-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.0 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for yamelish-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6b7cb0a42e7067132e3bcb43e51b385fde925fda2ecedc71f43591589491ebc7
MD5 43960cc91f3d42ffc280b4c597fefe7b
BLAKE2b-256 b2d5d0084e33bea025dc3e872d980f8ac86606fb57f72ab60ba3b9c94a715b61

See more details on using hashes here.

Supported by

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