docker-jsonlint

🐳 Dockerized jsonlint with proper versioning, a JSON parser and validator.

Stars
3

docker-jsonlint

Dockerized jsonlint with various versions, easy to use and easy to integrate with CI.

Table of Contents

Usage

Command line

Use latest version

docker run --rm -v $PATH_TO_JSON:/json peterdavehello/jsonlint jsonlint -q JSON_FILE.json

# Please replace "$PATH_TO_JSON" with your custom path,
# and replace "JSON_FILE.json" with your real json file filename.

Use specific version

Just like above, but you can specify version of jsonlint, for example:

docker run --rm -v $PATH_TO_JSON:/json peterdavehello/jsonlint:1.6.3 jsonlint -q JSON_FILE.json

# Please replace "1.6.3" with the version number you want.
# Don't forget to replace "$PATH_TO_JSON" & "JSON_FILE.json".

Continuous Integration (CI)

Travis CI

Enable Docker service in your .travis.yml:

services:
  - docker

And use the same command in the scripts part as the command line mentions, for example:

services:
  - docker

scripts:
  - docker run --rm -v $TRAVIS_BUILD_DIR:/json peterdavehello/jsonlint:1.6.3 jsonlint -q example.json

This will lint a example json file called example.json

GitLab CI

Add this block to your .gitlab-ci.yml:

jsonlint:
  stage: lint
  variables:
    jsonlint_version: "1.6.3"
  image: peterdavehello/jsonlint:$jsonlint_version
  only:
    changes:
      - "**/*.json"
  script:
    - find . -name "*.json" | xargs -n 1 jsonlint -q

Replace "1.6.3" with the version you want to use, you can also use "latest" for the very new version.

jsonlint cli usage

Just pass -h/--help to jsonlint to get its help message, for example:

$ docker run --rm peterdavehello/jsonlint jsonlint --help

Usage: jsonlint [file] [options]

file     file to parse; otherwise uses stdin

Options:
   -v, --version            print version and exit
   -s, --sort-keys          sort object keys
   -i, --in-place           overwrite the file
   -t CHAR, --indent CHAR   character(s) to use for indentation  [  ]
   -c, --compact            compact error display
   -V, --validate           a JSON schema to use for validation
   -e, --environment        which specification of JSON Schema the validation file uses  [json-schema-draft-03]
   -q, --quiet              do not print the parsed json to STDOUT  [false]

For more details, check out the jsonlint project page.

Build

Build command, you need to specify a valid jsonlint version argument to jsonLINT_VERSION:

docker build --build-arg JSONLINT_VERSION="1.6.3" -t docker-jsonlint .

# Replace "docker-jsonlint" with the preferred image name

You can find a valid version on jsonlint npm registry page, or just poke the registry to retrieve more details.

Badges
Extracted from project README
Build Status Docker Hub pulls Docker Hub badge