Application Integration でサポートされているコネクタをご覧ください。

2 つの JSON 配列を結合する

データ マッピング タスクを使用して、2 つの JSON 配列をマージし、結果の出力を新しい JSON 変数に保存します。

コードサンプル

{
    "triggerConfigs": [{
      "label": "API Trigger",
      "startTasks": [{
        "taskId": "1"
      }],
      "properties": {
        "Trigger name": "test_string_case_conversion_API_1"
      },
      "triggerType": "API",
      "triggerNumber": "1",
      "triggerId": "api_trigger/test_string_case_conversion_API_1"
    }],
    "taskConfigs": [{
      "task": "FieldMappingTask",
      "taskId": "1",
      "parameters": {
        "FieldMappingConfigTaskParameterKey": {
          "key": "FieldMappingConfigTaskParameterKey",
          "value": {
            "jsonValue": "{\n  \"@type\": \"type.googleapis.com/enterprise.crm.eventbus.proto.FieldMappingConfig\",\n  \"mappedFields\": [{\n    \"inputField\": {\n      \"fieldType\": \"JSON_VALUE\",\n      \"transformExpression\": {\n        \"initialValue\": {\n          \"referenceValue\": \"$inputJsonArray1$\"\n        },\n        \"transformationFunctions\": [{\n          \"functionType\": {\n            \"jsonFunction\": {\n              \"functionName\": \"MERGE\"\n            }\n          },\n          \"parameters\": [{\n            \"initialValue\": {\n              \"referenceValue\": \"$inputJsonArray2$\"\n            }\n          }]\n        }]\n      }\n    },\n    \"outputField\": {\n      \"referenceKey\": \"$outputJsonArray$\",\n      \"fieldType\": \"JSON_VALUE\",\n      \"cardinality\": \"OPTIONAL\"\n    }\n  }]\n}"
          }
        }
      },
      "taskExecutionStrategy": "WHEN_ALL_SUCCEED",
      "displayName": "Data Mapping"
    }],
    "integrationParameters": [{
      "key": "outputJsonArray",
      "dataType": "JSON_VALUE",
      "displayName": "outputJsonArray"
    }, {
      "key": "inputJsonArray1",
      "dataType": "JSON_VALUE",
      "defaultValue": {
        "jsonValue": "[{\n  \"name\": \"Abhishek\",\n  \"course\": \"Mechanical\"\n}, {\n  \"name\": \"Chirag\",\n  \"course\": \"Civil\"\n}, {\n  \"name\": \"Sachin\",\n  \"course\": \"Medical\"\n}, {\n  \"name\": \"Vivek\",\n  \"course\": \"Software\"\n}]"
      },
      "displayName": "inputJsonArray1",
      "jsonSchema": "{\n  \"$schema\": \"http://json-schema.org/draft-04/schema#\",\n  \"type\": \"array\",\n  \"items\": {\n    \"type\": \"object\",\n    \"properties\": {\n      \"name\": {\n        \"type\": \"string\"\n      },\n      \"course\": {\n        \"type\": \"string\"\n      }\n    }\n  }\n}"
    }, {
      "key": "inputJsonArray2",
      "dataType": "JSON_VALUE",
      "defaultValue": {
        "jsonValue": "[{\n  \"name\": \"Shubham\",\n  \"course\": \"IT\"\n}, {\n  \"name\": \"Dravid\",\n  \"course\": \"Mechanical\"\n}]"
      },
      "displayName": "inputJsonArray2",
      "jsonSchema": "{\n  \"$schema\": \"http://json-schema.org/draft-04/schema#\",\n  \"type\": \"array\",\n  \"items\": {\n    \"type\": \"object\",\n    \"properties\": {\n      \"name\": {\n        \"type\": \"string\"\n      },\n      \"course\": {\n        \"type\": \"string\"\n      }\n    }\n  }\n}"
    }],
    "userLabel": "v1"
  }

統合フローのサンプル

次の図は、この統合コードサンプルの統合エディタのサンプル レイアウトを示しています。

統合フローのサンプルを示す画像 統合フローのサンプルを示す画像

サンプル統合をアップロードして実行する

サンプル統合をアップロードして実行するには、次の手順に従います。

  1. 統合サンプルを .json ファイルとしてシステムに保存します。
  2. Google Cloud コンソールで [Application Integration] ページに移動します。

    Application Integration に移動

  3. ナビゲーション メニューで [統合] をクリックします。[統合リスト] ページが表示されます。
  4. 既存の統合を選択するか、[統合を作成] をクリックして新しい統合を作成します。

    新しい統合を作成する場合:

    1. [統合の作成] ダイアログで名前と説明を入力します。
    2. 統合のリージョンを選択します。
    3. 統合用のサービス アカウントを選択します。統合のサービス アカウントの詳細は、統合ツールバーの [統合の概要] ペインでいつでも変更または更新できます。
    4. [作成] をクリックします。

    統合エディタで統合が開きます。

  5. 統合エディタで、 [アップロード / ダウンロード メニュー] をクリックし、[統合をアップロード] を選択します。
  6. ファイル ブラウザ ダイアログで、ステップ 1 で保存したファイルを選択し、[開く] をクリックします。

    統合の新しいバージョンは、アップロードされたファイルを使用して作成されます。

  7. 統合エディタで [テスト] をクリックします。
  8. [テスト統合] をクリックします。統合が実行され、[テスト統合] ペインに実行結果が表示されます。