WebhookによるJSON文字列の検証

中級

これはBuilding Blocks分野の自動化ワークフローで、6個のノードを含みます。主にCode, Webhook, RespondToWebhookなどのノードを使用。 WebhookによるJSON文字列の検証

前提条件
  • HTTP Webhookエンドポイント(n8nが自動生成)
ワークフロープレビュー
ノード接続関係を可視化、ズームとパンをサポート
ワークフローをエクスポート
以下のJSON設定をn8nにインポートして、このワークフローを使用できます
{
  "id": "6GzSyLakqBN2hYIe",
  "meta": {
    "instanceId": "1777696fb9fddfee653e70940936c2b1e28ba1f1bde53b7182fbd6eb01988706"
  },
  "name": "JSON String Validator via Webhook",
  "tags": [],
  "nodes": [
    {
      "id": "72785a1d-32f6-4f0d-a412-5327c059ddd3",
      "name": "JSON 文字列の受信",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -680,
        -140
      ],
      "webhookId": "2604aa77-b575-4c3f-b1df-feab9c775603",
      "parameters": {
        "path": "validate-json-string",
        "options": {},
        "httpMethod": "POST",
        "responseMode": "responseNode"
      },
      "typeVersion": 2
    },
    {
      "id": "940b04da-3f16-434d-8181-9452dd3ba007",
      "name": "Webhook への結果返信",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        100,
        -140
      ],
      "parameters": {
        "options": {},
        "respondWith": "allIncomingItems"
      },
      "typeVersion": 1.2
    },
    {
      "id": "4546866f-9376-47cf-ac19-caf0eb197cca",
      "name": "コード: JSON 文字列の検証",
      "type": "n8n-nodes-base.code",
      "position": [
        -300,
        -140
      ],
      "parameters": {
        "jsCode": "// This node validates if the 'jsonString' in the webhook body is valid JSON.\n// It returns 'valid: true' or 'valid: false' along with an error message if invalid.\n\nconst results = [];\n\nfor (const item of $input.all()) {\n  try {\n    // Attempt to parse the jsonString from the webhook body\n    // Ensure 'jsonString' exists before attempting to parse\n    if (item.json.body && typeof item.json.body.jsonString === 'string') {\n      JSON.parse(item.json.body.jsonString);\n      results.push({ json: { valid: true } });\n    } else {\n      // Handle cases where jsonString is missing or not a string\n      results.push({ json: { valid: false, error: \"Input 'jsonString' is missing or not a string.\" } });\n    }\n  } catch (e) {\n    // If parsing fails, push the error message\n    results.push({ json: { valid: false, error: e.message } });\n  }\n}\n\nreturn results;"
      },
      "typeVersion": 2
    },
    {
      "id": "52ea0a9b-863d-4d09-b96b-ab707571738b",
      "name": "注記: Webhook 入力",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -760,
        -360
      ],
      "parameters": {
        "width": 280,
        "height": 380,
        "content": "## Webhook Input\n\nThis node listens for incoming POST requests. It expects a JSON body containing a single property: `jsonString` (the string you wish to validate as JSON)."
      },
      "typeVersion": 1
    },
    {
      "id": "f3f93504-93b2-40e9-93e6-45366a681ac0",
      "name": "注記: JSON 検証ロジック",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -420,
        -320
      ],
      "parameters": {
        "color": 2,
        "width": 350,
        "height": 360,
        "content": "## JSON Validation Logic\n\nThis node contains custom JavaScript code to parse the `jsonString` from the webhook input. It returns `valid: true` if successful, or `valid: false` with an `error` message if parsing fails."
      },
      "typeVersion": 1
    },
    {
      "id": "e8632087-424b-40b4-a894-301885137f49",
      "name": "注記: Webhook レスポンス",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        -320
      ],
      "parameters": {
        "color": 3,
        "width": 350,
        "height": 360,
        "content": "## Webhook Response\n\nThis node sends the validation result (whether the `jsonString` was valid JSON or not, including an error if applicable) back to the system that triggered the webhook."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "ecec4bf1-c92e-485f-9f8f-fc98441310eb",
  "connections": {
    "4546866f-9376-47cf-ac19-caf0eb197cca": {
      "main": [
        [
          {
            "node": "940b04da-3f16-434d-8181-9452dd3ba007",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "72785a1d-32f6-4f0d-a412-5327c059ddd3": {
      "main": [
        [
          {
            "node": "4546866f-9376-47cf-ac19-caf0eb197cca",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
よくある質問

このワークフローの使い方は?

上記のJSON設定コードをコピーし、n8nインスタンスで新しいワークフローを作成して「JSONからインポート」を選択、設定を貼り付けて認証情報を必要に応じて変更してください。

このワークフローはどんな場面に適していますか?

中級 - ビルディングブロック

有料ですか?

このワークフローは完全無料です。ただし、ワークフローで使用するサードパーティサービス(OpenAI APIなど)は別途料金が発生する場合があります。

関連ワークフロー

Webhookを使ってScreenshotMachine APIを使用してウェブサイトのスクリーンショットをリアルタイムで生成する
ScreenshotMachine APIをWebhooks経由でウェブサイトのスクリーンショットを需要に応じて生成する
If
Code
Webhook
+
If
Code
Webhook
12 ノードist00dent
ビルディングブロック
Webhook を通じたコンテンツ要約ジェネレーター (ApyHub)
Webhook を使った要約生成ツール (ApyHub)
Webhook
Http Request
Respond To Webhook
+
Webhook
Http Request
Respond To Webhook
8 ノードist00dent
ビルディングブロック
タイムゾーンDB APIを使用して時差を変換する
TimeZoneDB API統合を使用してタイムゾーンを変換する
Webhook
Http Request
Respond To Webhook
+
Webhook
Http Request
Respond To Webhook
6 ノードist00dent
ビルディングブロック
ExchangeRate.host を Webhook を使って通貨変換を自動化
ExchangeRate.host を使って Webhook で為替レート変換を実行
Webhook
Http Request
Respond To Webhook
+
Webhook
Http Request
Respond To Webhook
6 ノードist00dent
ビルディングブロック
Webhook経由でのIPジオロケーション検索
Webhookを使用してIP-API.comでIPの地理位置詳細をクエリ
Webhook
Http Request
Respond To Webhook
+
Webhook
Http Request
Respond To Webhook
6 ノードist00dent
ビルディングブロック
day9_暗号通貨の更新情報取得
CoinGeckoを使って暗号通貨市場:ボラティリティ指標と投資シグナル
If
Set
Switch
+
If
Set
Switch
26 ノードist00dent
財務
ワークフロー情報
難易度
中級
ノード数6
カテゴリー1
ノードタイプ4
難易度説明

経験者向け、6-15ノードの中程度の複雑さのワークフロー

作成者
ist00dent

ist00dent

@ist00dent

I’m a dedicated automation engineer passionate about no-code and low-code solutions. I design and implement robust n8n workflows—integrating APIs, databases, and messaging—to eliminate manual tasks and accelerate delivery. Leveraging Python and C#, I build scalable, adaptable automations that empower teams to focus on high-value work.

外部リンク
n8n.ioで表示

このワークフローを共有

カテゴリー

カテゴリー: 34