עדכון מערך JSON באינדקס שצוין

בעזרת המשימה Data Mapping, מעדכנים את הערך של מערך JSON באינדקס מסוים באמצעות משתנה קלט. שומרים את הפלט במשתנה JSON חדש.

דוגמת קוד

{
  "triggerConfigs": [{
    "label": "API Trigger",
    "startTasks": [{
      "taskId": "1"
    }],
    "properties": {
      "Trigger name": "tkApplicationIntegrationSample1_API_1"
    },
    "triggerType": "API",
    "triggerNumber": "1",
    "triggerId": "api_trigger/tkApplicationIntegrationSample1_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\": \"$jsonArray$\"\n        },\n        \"transformationFunctions\": [{\n          \"functionType\": {\n            \"jsonFunction\": {\n              \"functionName\": \"TO_STRING_ARRAY\"\n            }\n          }\n        }, {\n          \"functionType\": {\n            \"stringArrayFunction\": {\n              \"functionName\": \"SET\"\n            }\n          },\n          \"parameters\": [{\n            \"initialValue\": {\n              \"literalValue\": {\n                \"intValue\": \"2\"\n              }\n            }\n          }, {\n            \"initialValue\": {\n              \"referenceValue\": \"$jsonVar$\"\n            },\n            \"transformationFunctions\": [{\n              \"functionType\": {\n                \"jsonFunction\": {\n                  \"functionName\": \"TO_STRING\"\n                }\n              }\n            }]\n          }]\n        }, {\n          \"functionType\": {\n            \"stringArrayFunction\": {\n              \"functionName\": \"TO_JSON\"\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",
    "inputOutputType": "OUT",
    "jsonSchema": "{\n  \"$schema\": \"http://json-schema.org/draft-04/schema#\",\n  \"type\": \"array\",\n  \"items\": {\n    \"type\": \"object\",\n    \"properties\": {\n      \"prop1\": {\n        \"type\": \"string\"\n      }\n    }\n  }\n}"
  }, {
    "key": "jsonArray",
    "dataType": "JSON_VALUE",
    "defaultValue": {
      "jsonValue": "[{\n  \"prop1\": \"val11\"\n}, {\n  \"prop1\": \"val21\"\n}, {\n  \"prop1\": \"val31\"\n}, {\n  \"prop1\": \"val41\"\n}]"
    },
    "displayName": "jsonArray",
    "jsonSchema": "{\n  \"$schema\": \"http://json-schema.org/draft-04/schema#\",\n  \"type\": \"array\",\n  \"items\": {\n    \"type\": \"object\",\n    \"properties\": {\n      \"prop1\": {\n        \"type\": \"string\"\n      }\n    }\n  }\n}"
  }, {
    "key": "jsonVar",
    "dataType": "JSON_VALUE",
    "defaultValue": {
      "jsonValue": "{\n  \"prop1\": \"valUserDefined\"\n}"
    },
    "displayName": "jsonVar",
    "jsonSchema": "{\n  \"$schema\": \"http://json-schema.org/draft-04/schema#\",\n  \"type\": \"object\",\n  \"properties\": {\n    \"prop1\": {\n      \"type\": \"string\"\n    }\n  }\n}"
  }]
}

תהליך שילוב לדוגמה

בתמונה הבאה מוצגת פריסה לדוגמה של עורך השילובים עבור דוגמת הקוד הזו.

תמונה שמציגה את תהליך השילוב לדוגמה תמונה שמציגה את תהליך השילוב לדוגמה

העלאה והפעלה של השילוב לדוגמה

כדי להעלות ולהריץ את השילוב לדוגמה:

  1. שומרים את השילוב לדוגמה כקובץ ‎ .json במערכת.
  2. נכנסים לדף Application Integration במסוף Google Cloud.

    לדף Application Integration

  3. בתפריט הניווט שמימין, לוחצים על שילובים כדי לפתוח את הדף שילובים.
  4. בוחרים שילוב קיים או יוצרים שילוב חדש בלחיצה על יצירת שילוב.

    אם אתם יוצרים שילוב חדש:

    1. מזינים שם ותיאור בתיבת הדו-שיח Create Integration.
    2. בוחרים אזור לשילוב.
    3. בוחרים חשבון שירות לשילוב. אתם יכולים לשנות או לעדכן את פרטי חשבון השירות של שילוב בכל שלב, דרך החלונית Integration summary (סיכום השילוב) בסרגל הכלים של השילוב.
    4. לוחצים על יצירה.

    האינטגרציה תיפתח בכלי לעריכת אינטגרציות.

  5. בכלי לעריכת אינטגרציות, לוחצים על התפריט Upload/download ובוחרים באפשרות Upload integration.
  6. בתיבת הדו-שיח של דפדפן הקבצים, בוחרים את הקובץ ששמרתם בשלב 1 ולוחצים על פתיחה.

    גרסה חדשה של האינטגרציה נוצרת באמצעות הקובץ שהועלה.

  7. בכלי לעריכת אינטגרציות, לוחצים על Test.
  8. לוחצים על Test integration (בדיקת השילוב). הפעולה הזו מריצה את האינטגרציה ומציגה את תוצאת ההפעלה בחלונית Test Integration.