jsonlint

表題について。たまたま知ったので試してみた。

■ 環境

  • jsonlint 1.6.0
  • Homebrew
  • macOS High SIerra

■ jsonlint

検索。

$ brew update
$ brew search jsonlint
==> Formulae
jsonlint
$

インストール。

$ brew install jsonlint

インストールされたものは下記のようである。

$ brew ls jsonlint
/usr/local/Cellar/jsonlint/1.6.0/bin/jsonlint
/usr/local/Cellar/jsonlint/1.6.0/libexec/bin/jsonlint
/usr/local/Cellar/jsonlint/1.6.0/libexec/lib/ (275 files)
$

ヘルプを確認してみる。

$ 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]
   -p, --pretty-print       force pretty printing even if invalid

$

試しにJSONの体をなしていないファイルで試してみると下記のようになった。

$ jsonlint sample.json
Error: Parse error on line 3:
...      {            Request": {
----------------------^
Expecting 'STRING', '}', got 'undefined'
  :

」が無いことを知らせてくれた。

$ jsonlint sample.json
Error: Parse error on line 8:
...          "Method": "GET
-----------------------^
Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '[', got 'undefined'
  :

,」が無いことを知らせてくれた。

とりあえずは自分がやりたいことには使えそうである。

以上。

コメントを残す

メールアドレスが公開されることはありません。

CAPTCHA


このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください