<predstore>
タグでは、PredicateStore記法を使用して、JSONデータの作成や編集を行うことができます。
また、<predstore>
タグでは、同記法以外にPredicateStore関数も使用できます。
(PredicateStore関数の利用方法については、こちらをご覧ください)
JSONデータの例
1 2 3 4 5 6 7 |
{ "family":{ "father":"太郎", "mother":"花子", "children":["一郎","次郎"] } } |
作成したJSONデータは、<ext>
タグによるサービス連携や、クライアントアプリとのデータ連携などに利用することができます。
データ操作方法
<predstore>
タグで、データを操作する方法について説明いたします。
Object名
Object名に利用可能な記号はハイフン(-)とアンダースコア(_)のみで、文字列は半角スペースを含まない半角英数字、日本語(ひらがな・カタカナ・漢字)になります。
データ操作記法
<predstore>
タグで使用できるデータ操作記法について説明いたします。
構文エラー及び存在しないObject名を指定した場合は、undefined
を返却します。
記法 | 返却値 | 説明 |
Object.Key |
Object.Key の値 |
Object.Key の値を取得します。 |
Object.* |
Object 配下の全ての値 |
Object 配下の全ての値を取得します。(スペース区切り) |
Object.Key=Value |
Value の値 |
Object.Key にValue を設定します。 |
Object1=$Object2 |
Object の値 |
Object1 にObject2 を設定します。 |
!Object |
OK |
Object を削除します。 |
(Value1 Value2 Value3) |
Value1 Value2 Value3 |
Value1 Value2 Value3 を1つのリストにまとめます。 |
Object=$(Value1 Value2 Value3) |
Value1 Value2 Value3 |
Value1 Value2 Value3 のリストとしてObjectに設定します。 |
データ操作例
データ設定
Object.Key=Value
記法を使い、Object.Keyにデータを設定します。
xAIML
1 2 3 |
<template> <predstore>family.father=太郎</predstore> </template> |
実行結果
1 |
太郎 |
データ構造
実行前
1 2 3 4 5 |
undefined |
実行後
1 2 3 4 5 |
{ "family":{ "father":"太郎" } } |
Object.Key=Value
記法を使い、既存のデータに値を追加する例です。
xAIML
1 2 3 |
<template> <predstore>family.mother=花子</predstore> </template> |
実行結果
1 |
花子 |
データ構造
実行前
1 2 3 4 5 6 |
{ "family":{ "father":"太郎" } } |
実行後
1 2 3 4 5 6 |
{ "family":{ "father":"太郎", "mother":"花子" } } |
Object=$(Value1 Value2 Value3)
記法を使い、リストデータを設定する例です。
xAIML
1 2 3 |
<template> <predstore>family.children=$(一郎 次郎)</predstore> </template> |
実行結果
1 |
一郎 次郎 |
データ構造
実行前
1 2 3 4 5 6 7 |
{ "family":{ "father":"太郎", "mother":"花子" } } |
実行後
1 2 3 4 5 6 7 |
{ "family":{ "father":"太郎", "mother":"花子", "children":["一郎","次郎"] } } |
データ取得
以下のデータからfamily
配下の値を取得する例です。
1 2 3 4 5 6 7 |
{ "family":{ "father":"太郎", "mother":"花子", "children":["一郎","次郎"] } } |
Object.Key
記法を使い、値を取得します。
xAIML
1 2 3 |
<template> <predstore>family.father</predstore> </template> |
実行結果
1 |
太郎 |
Object
記法を使い、Object配下のkey一覧を取得します。
xAIML
1 2 3 |
<template> <predstore>family</predstore> </template> |
実行結果
1 |
father mother children |
Object.*
記法を使い、Object配下の全てのValueを取得します。
xAIML
1 2 3 |
<template> <predstore>family.*</predstore> </template> |
実行結果
1 |
太郎 花子 一郎 次郎 |
データ削除
Objectを削除または初期化する例です。
!Object
記法を使い、Objectを削除します。
xAIML
1 2 3 |
<template> <predstore>!family.children</predstore> </template> |
実行結果
1 |
OK |
データ構造
実行前
1 2 3 4 5 6 7 |
{ "family":{ "father":"太郎", "mother":"花子", "children":["一郎","次郎"] } } |
実行後
1 2 3 4 5 6 7 |
{ "family":{ "father":"太郎", "mother":"花子" } } |
Object.Key=Value
記法を使い、Object.Keyの値を削除します。
xAIML
1 2 3 |
<template> <predstore>family.father=</predstore> </template> |
実行結果
1 |
1 2 3 4 5 6 |
{ "family":{ "father":"太郎", "mother":"花子" } } |
実行後
1 2 3 4 5 6 |
{ "family":{ "father":"", "mother":"花子" } } |
Object.Key=Value
記法を使い、Object.keyのリスト内容を削除します。
xAIML
1 2 3 |
<template> <predstore>family.children=$()</predstore> </template> |
実行結果
1 |
1 2 3 4 5 6 7 |
{ "family":{ "father":"太郎", "mother":"花子", "children":["一郎","次郎"] } } |
実行後
1 2 3 4 5 6 7 |
{ "family":{ "father":"太郎", "mother":"花子", "children":[] } } |