# JSONスキーマをインポート

Talend Data Mapperを使用すると、JSONスキーマからJSONストラクチャーを作成できます。

JSONスキーマエレメントのサポートについては、[JSONスキーマサポート](https://help.qlik.com/talend/ja-JP/data-mapper-user-guide/8.0/json-schema-support)をご覧ください。

Talend Data MapperはJSONドキュメントの検証にJSONスキーマを使用しません。JSONスキーマは、JSONストラクチャーを作成するためのモデルとしてのみ使われます。たとえば、文字列が"maxLength": 15と定義されている場合、長さが15文字を超えてもエラーが返されません。

## 始める前に

* インポートするJSONスキーマファイルがあること。
* 無視する必要のある参照を [Window] (ウィンドウ) &gt; [Preferences] (環境設定) &gt; [Mapping] (マッピング) &gt; [Representations] (表記)の [Reference blacklist] (参照のブラックリスト)に追加していること。詳細は、[表記の環境設定](https://help.qlik.com/talend/ja-JP/data-mapper-user-guide/8.0/representation-preferences)をご覧ください。

## このタスクについて

この例では、次のJSONスキーマを使用します:

```
{
    "$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"
						}
					}
				}
					
            }
        }
    }
}
```

## 手順

1. [Data Mapper]タブで[Hierarchical Mapper] (階層マッパー)ノードを展開し、[Structures] (ストラクチャー)を右クリックします。
2. [New] (新規) &gt; [Structure] (ストラクチャー)をクリックします。
3. ウィザードが開いたら、[Import a structure definition] (ストラクチャー定義をインポート)を選択して[Next] (次へ)をクリックします。
4. インポートのタイプ(この例では[JSON Schema] (JSONスキーマ))を選択し、[Next] (次へ)をクリックします。
5. 使用するファイルを選択します:
   * ワークスペースで既存のリソースを選択します。
   * ローカルファイルをインポートします。
   * このファイルにURLを入力します。
6. [Next] (次へ)をクリックします。
7. フォルダーを選択して新しいストラクチャーの名前を入力し、[Next] (次へ)をクリックします。
8. [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"
         }
      }
   ]
}
```

結果は次のようになります。 ![スキーマの結果。](https://help.qlik.com/talend/ja-JP/data-mapper-user-guide/Resources/images/import_json_schema_02_result.png)

### このセクション内

* [JSONスキーマのサポート](https://help.qlik.com/talend/ja-JP/data-mapper-user-guide/8.0-R2025-10/json-schema-support)