JSONスキーマをインポート
Talend Data Mapperを使用すると、JSONスキーマからJSONストラクチャーを作成できます。
JSONスキーマエレメントのサポートについては、JSONスキーマのサポートをご覧ください。
Talend Data MapperはJSONドキュメントの検証にJSONスキーマを使用しません。JSONスキーマは、JSONストラクチャーを作成するためのモデルとしてのみ使われます。たとえば、文字列が"maxLength": 15と定義されている場合、長さが15文字を超えてもエラーが返されません。
情報メモ注: この機能は、Talendが提供するR2022-03以降のTalend Studioマンスリーアップデートをインストール済みである場合のみ利用できます。詳細は管理者にお問い合わせください。
  始める前に
- インポートするJSONスキーマファイルがあること。
 - 無視する必要のある参照を の [Reference blacklist] (参照のブラックリスト)に追加していること。詳細は、表記の環境設定をご覧ください。
 
このタスクについて
{
    "$id": "https://example.com/arrays.schema.json",
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "description": "A representation of a list of customers.",
    "type": "object",
    "properties": {
        "customers": {
            "type": "array",
            "items": {
                "$ref": "#/$defs/customer"
            }
        }
    },
    "$defs": {
        "customer": {
            "type": "object",
            "properties": {
                "LastName": {
                    "type": "string",
                    "description": "The customer's last name."
                },
                "firstName": {
                    "type": "string",
                    "description": "The customer's last name."
                },
				"address": {
					"type": "object",
					"description": "The customer's address.",
					"properties": {
						"street": {
							"type": "string"
						},
						"postCode": {
							"type": "integer"
						},
						"city": {
							"type": "string"
						},
						"state": {
							"type": "string"
						},
						"country": {
							"type": "string"
						}
					}
				}
					
            }
        }
    }
}手順
- [Data Mapper]タブで[Hierarchical Mapper] (階層マッパー)ノードを展開し、[Structures] (ストラクチャー)を右クリックします。
 - をクリックします。
 - ウィザードが開いたら、[Import a structure definition] (ストラクチャー定義をインポート)を選択して[Next] (次へ)をクリックします。
 - インポートのタイプ(この例では[JSON Schema] (JSONスキーマ))を選択し、[Next] (次へ)をクリックします。
 - 
        使用するファイルを選択します:
        
- ワークスペースで既存のリソースを選択します。
 - ローカルファイルをインポートします。
 - このファイルにURLを入力します。
 
 - [Next] (次へ)をクリックします。
 - フォルダーを選択して新しいストラクチャーの名前を入力し、[Next] (次へ)をクリックします。
 - [Finish] (終了)をクリックします。
 
タスクの結果
JSONストラクチャーはスキーマで指定されたすべてのエレメントで作成されます。このスキーマに従ってサンプルドキュメントをインポートすると、正しくハイライトされたエレメントが表示されます。この例で使用されたスキーマで次のサンプルをインポートできます:
      {
   "customers":[
      {
         "lastName":"Smith",
         "firstName":"Jane",
         "address":{
            "street":"4876 Felosa Drive",
            "postCode":90017,
            "city":"Los Angeles",
            "state":"CA",
            "country":"United States"
         }
      },
	  {
         "lastName":"Doe",
         "firstName":"John",
         "address":{
            "street":"4862 Parkway Street",
            "postCode":92203,
            "city":"Bermuda Dunes",
            "state":"CA",
            "country":"United States"
         }
      }
   ]
}結果は次のようになります。