AppML リファレンス - データファイル


"data" プロパティ

"data" property defines a data file as the data source. It has the following sub properties:

属性 説明
"type" データファイルのタイプ ("csvfile", "xmlfile", "jsonfile")
"filename" ファイル名
"record" XML データのノード名 (xml ファイルの場合)
"items" データ項目

テキストファイルのデータ

このモデルは、csv ファイルから Title、Artist、Price を含むレコードを item 1, 2, 5 として取得(fetch)します:

モデル

{
"data": {
    "type"    : "csvfile",
    "filename": "cd_catalog.txt",
    "items"   : [
        {"name": "Title", "index": 1},
        {"name": "Artist","index": 2},
        {"name": "Price", "index": 5}
    ]
}
}
Try It Yourself »

例の説明:ケース テキストファイル


XML ファイルのデータ

このモデルは、XML ファイルの CD ノードから Title、Artist、Price を含むレコードを取得(fetch)します:

モデル

{
"data": {
    "type"    : "xmlfile",
    "filename": "cd_catalog.xml",
    "record"  : "CD",
    "items"   : [
        {"name": "Artist", "nodename": "ARTIST"},
        {"name": "Title",  "nodename": "TITLE"},
        {"name": "Country","nodename": "COUNTRY"}
    ]
}
}
Try It Yourself »

例の説明:ケース XML ファイル


JSON ファイルのデータ

このモデルは、JSON ファイルの CD オブジェクトの配列から Title、Artist、Price を含むレコードを取得(fetch)します:

モデル

{
"data" : {
    "type" : "jsonfile",
    "filename" : "cd_catalog.js",
    "record" : "cd",
    "items" : [
        {"name" : "Title", "nodename" : "title"},
        {"name" : "Artist", "nodename" : "artist"},
        {"name" : "Price", "nodename" : "price"}
    ]
}
}
Try It Yourself »

例の説明:ケース JSON ファイル