8
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

シンプルで使いやすいJSONフォーマットツールを作ってみた

8
Last updated at Posted at 2021-03-21

はじめに

こんにちは、システム開発チーム「presto」です。
開発業務(プログラミング中)に「こんなツール、あんなツールが身近なところにあったらいいなぁ」と思ったことはありませんか?

ここではそんなツールをVuetifyを使って作ってみたので紹介させてください。

JSONフォーマットツール

今回紹介させていただくのは、JSONフォーマットツールです。

画面は以下の通りです。

JSONフォーマットツール

使い方

使い方は以下の通りです。

  1. 画面上部のテキストエリアにJSON文字列を入力する
  2. (任意)フォーマットのインデント数を指定する
  3. 結果確認

1. 画面上部のテキストエリアにJSON文字列を入力する

JSONフォーマットツール_手順1

例として、以下を入力します。

{"number":12345,"result":true}

JSONフォーマットツール_手順1_入力内容

2. (任意)フォーマットのインデント数を指定する

デフォルトのインデント数は「4」となっています。

JSONフォーマットツール_手順2_インデント数指定

3. 結果確認

以下のような値が表示されます。

{
    "number": 12345,
    "result": true
}

JSONフォーマットツール_手順3_フォーマット結果

インデント数を「0」と指定すると、整形後のJSON文字列がMinifyされます。

{"number":12345,"result":true}

JSONフォーマットツール_手順3_インデント数指定_Minify

JSONフォーマットできない文字列を入力した場合

JSONフォーマットできない文字列を入力した場合、SyntaxErrorが表示されます。

SyntaxError: Unexpected token d in JSON at position 6

JSONフォーマットツール_SyntaxError

まとめ

今回は、JSONフォーマットツールの紹介をさせていただきました。

他にも、私達が作ったpresto web toolsの紹介もしていますので、良ければ合わせてご覧ください。

今後もよろしくお願いします。
ありがとうございましたー!

8
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?