數字

數字欄位由type: number表示,沒有其他必要屬性。

"sampleField": {
  "title": "Sample Number Field",
  "description": "An example number field.",
  "type": "number"
}
NOTE
number型別用於任何數值型別,可以是整數或浮點數,而integer型別則專門用於整數數字。 如需每種型別使用案例的詳細資訊,請參閱數值型別🔗的JSON結構描述檔案。

整數

整數欄位由type: integer表示,沒有其他必要欄位。

"sampleField": {
  "title": "Sample Integer Field",
  "description": "An example integer field.",
  "type": "integer"
}
NOTE
雖然integer型別是專門參照整數型別,但number型別用於任何數值型別,可以是整數或浮點數。 如需每種型別使用案例的詳細資訊,請參閱數值型別🔗的JSON結構描述檔案。

您可以將minimummaximum屬性新增至定義,選擇性地限制整數的範圍。 結構描述產生器UI支援的其他數位型別只有integer個具有特定minimummaximum限制條件的型別,例如LongShortByte

"sampleField": {
  "title": "Sample Integer Field",
  "description": "An example integer field with added constraints.",
  "type": "integer",
  "minimum": 1,
  "maximum": 100
}

與透過結構描述產生器UI建立的Long欄位等同的是integer型別欄位,具有特定minimummaximum值(分別為-90071992547409929007199254740992)。

"sampleField": {
  "title": "Sample Long Field",
  "description": "An example long field.",
  "type": "integer",
  "minimum": -9007199254740992,
  "maximum": 9007199254740992
}

短整數

與透過結構描述產生器UI建立的Short欄位等同的是integer型別欄位,具有特定minimummaximum值(分別為-3276832768)。

"sampleField": {
  "title": "Sample Short Field",
  "description": "An example short field.",
  "type": "integer",
  "minimum": -32768,
  "maximum": 32768
}

位元組

與透過結構描述產生器UI建立的位元組欄位相當的是integer型別欄位,具有特定的minimummaximum值(分別為-128128)。

"sampleField": {
  "title": "Sample Byte Field",
  "description": "An example byte field.",
  "type": "integer",
  "minimum": -128,
  "maximum": 128
}

布林值

布林值欄位由type: boolean表示。

"sampleField": {
  "title": "Sample Boolean Field",
  "description": "An example boolean field.",
  "type": "boolean"
}

您可以選擇提供當擷取期間未提供明確值時,欄位將使用的default值。

"sampleField": {
  "title": "Sample Boolean Field",
  "description": "An example boolean field with a default value.",
  "type": "boolean",
  "default": false
}
IMPORTANT
如果未提供default值,且布林欄位設定為required,則擷取時,任何遺失此欄位可接受值的記錄都將無法驗證。

日期

日期欄位由type: stringformat: date表示。 您也可選擇提供examples陣列,以便在您想要為手動輸入資料的使用者顯示範例日期字串時運用。

"sampleField": {
  "title": "Sample Date Field",
  "description": "An example date field with an example array item.",
  "type": "string",
  "format": "date",
  "examples": ["2004-10-23"]
}

日期時間

日期時間欄位由type: stringformat: date-time表示。 您也可以選擇提供examples陣列,以便在您要顯示手動輸入資料之使用者的範例日期時間字串時運用。

"sampleField": {
  "title": "Sample Datetime Field",
  "description": "An example datetime field with an example array item.",
  "type": "string",
  "format": "date-time",
  "examples": ["2004-10-23T12:00:00-06:00"]
}

陣列

陣列欄位由type: arrayitems物件表示,該物件定義陣列將接受的專案結構描述。

您可以使用基本型別(例如字串陣列)來定義陣列專案:

"sampleField": {
  "title": "Sample Array Field",
  "description": "An example array field using a primitive type.",
  "type": "array",
  "items": {
    "type": "string"
  }
}

您也可以透過$ref屬性參照資料型別的$id,根據現有的資料型別定義陣列專案。 下列是付款專案物件的陣列:

"sampleField": {
  "title": "Sample Array Field",
  "description": "An example array field using a data type reference.",
  "type": "array",
  "items": {
    "$ref": "https://ns.adobe.com/xdm/data/paymentitem"
  }
}

物件

物件欄位由type: object和定義結構描述欄位子屬性的properties物件表示。

properties下定義的每個子欄位都可以使用任何基本值type來定義,或是透過指向相關資料型別$id$ref屬性來參考現有的資料型別:

"sampleField": {
  "title": "Sample Object Field",
  "description": "An example object field.",
  "type": "object",
  "properties": {
    "field1": {
      "type": "string"
    },
    "field2": {
      "$ref": "https://ns.adobe.com/xdm/common/measure"
    }
  }
}

您也可以透過參考資料型別來定義整個物件,前提是相關資料型別本身定義為type: object

"sampleField": {
  "title": "Sample Object Field",
  "description": "An example object field using a data type reference.",
  "$ref": "https://ns.adobe.com/xdm/common/phoneinteraction"
}

地圖

對應欄位基本上是object型別的欄位,其索引鍵集不受限制。 如同物件,對應有typeobject,但其meta:xdmType已明確設定為map

對應​ 不得 ​定義任何屬性。 它​ 必須 ​定義單一additionalProperties結構描述以說明對應中包含的值型別(每個對應只能包含單一資料型別)。 type值必須是stringinteger

例如,具有字串型別值的對應欄位會定義如下:

"sampleField": {
  "title": "Sample Map Field",
  "description": "An example map field.",
  "type": "object",
  "meta:xdmType": "map",
  "additionalProperties": {
    "type": "string"
  }
}

如需建立自訂對應欄位的詳細資訊,請參閱下節。

建立自訂地圖型別

為了在XDM中有效支援「類似對應」資料,物件可能會被設為mapmeta:xdmType註釋,以明確表示物件應像金鑰集未受限制一樣受到管理。 擷取至對應欄位的資料必須使用字串鍵,而且只能使用字串或整數值(由additionalProperties.type決定)。

XDM對於此儲存提示的使用會設定下列限制:

  • 對應型別必須屬於型別object
  • 對應型別不得有已定義的屬性(換言之,它們會定義「空白」物件)。
  • 對應型別必須包含additionalProperties.type欄位,描述可能放置在對應中的值: stringinteger

請確定您只在絕對必要時才使用對應型別欄位,因為這些欄位具有下列效能缺陷:

Experience Platform使用者介面在擷取對應型別欄位索引鍵的方式上也有限制。 雖然物件型別欄位可以展開,但地圖會顯示為單一欄位。