Skip to main content

Simple test-suite for json/yaml files, optimized for CI pipelines.

Project description

jMatch

jMatch is a testsuite for JSON/YAML files. It allows you to check these files against a specification based on defined patterns. This is useful if you need to check lots of JSON files or if you want to check your JSON files in a continuous integration pipeline.

Table of Contents

Installation

Install via PIP

Make sure, you have python3 with pip installed. Use pip to install jMatch in your shell as follows:

pip install jmatch

Usage

As soon as jMatch is installed, it is used to check JSON/YAML documents against a predefined specification. jMatch uses JSON/YAML to define specification options as a search pattern.

Example Specification Pattern

Example usecase: Imagine, a bunch of JSON-formated config files, all of those config files should specify the same text-encoding (UTF-8) to make sure that all systems interoperate correctly.

Solution: To implement a solution for the given usecase, another JSON-document needs to be specified, which contains at least the following data concerning the given problem.

  • type: info or error
  • message: A message to print if the pattern matches
  • pattern: An info or error case pattern that is searched in the document to check.
[{
  "_type": "error",
  "_message": "The encoding should be UTF-8, but it is not.",
  "_pattern": {
    "encoding": {"_not": "UTF-8"}
  }
}]

We want to mark the problem as critical, we use the error type. If used in a CI-pipeline, the type error forces the Pipeline to fail, if the pattern matches. For the pattern we want to search for a encoding, with a value different from UTF-8.

Check if the pattern exists in a JSON document

If we want to check a configfile.json file if it matches our check-encoding-utf8.json. We can perform the following operation, assuming that both files are in our current working directory:

jmatch --target configfile.json check-encoding-utf8.json

If the configfile contains the pattern specified in check-encoding-utf8.json, the _message specified is displayed.

Check for multiple patterns at once

jMatch allows to check many patterns at once, therefore all pattern files must be provided when running jMatch.

jmatch --target configfile.json pattern1.json pattern2.json [...]

To provide multiple pattern files for jMatch, wildcard expressions can be used, to specify many pattern files easily:

jmatch --target hello.json pattern*.json

Flags

There are many different flags which change jMatchs default behavior. You can use the --help flag to show all available options.

Support

Please open an issue for support.

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

jmatch-0.4.tar.gz (11.4 kB view details)

Uploaded Source

Built Distribution

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

jmatch-0.4-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file jmatch-0.4.tar.gz.

File metadata

  • Download URL: jmatch-0.4.tar.gz
  • Upload date:
  • Size: 11.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.4

File hashes

Hashes for jmatch-0.4.tar.gz
Algorithm Hash digest
SHA256 042cda5fafbbd8633d4d9d6a6f41dfa8e776d62c065b3d6d212e9f3140263f8a
MD5 be9682a275055e7d7eab9a63082ca954
BLAKE2b-256 71d9d6147c3d5435dad472fe2dfb554178a557f7d6f5fd8d8b8d0075398f9d2c

See more details on using hashes here.

File details

Details for the file jmatch-0.4-py3-none-any.whl.

File metadata

  • Download URL: jmatch-0.4-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.4

File hashes

Hashes for jmatch-0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 a24ea0dbdbd9bce1d426e088e962a6d1d857226e7d74975f18b54ddbbe5f0f30
MD5 0f5ef0f3561427b6bd8ef99427c4b78f
BLAKE2b-256 b941ca657fb02cb1b5e01a415b7833cc3ad9f8ecfe88c683a897372755f6985f

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