Page History
...
Read…WithPath
...
メソッドを使って、パスでによって
...
JSON
...
データ内の位置が指定された値を読み込みます。パスは、スラッシュで区切られた一連のメンバ名、アレイ・インデックスです。
...
例えば、前回の例にあった以下の
...
JSON
...
文字列を使うとします。
...
{ "name":
...
{ "given":"John",
...
"surname":"Smith"
...
},
...
...
...
"given"
...
のメンバ値
...
(John)
...
へのパスは、"name/given".となります。
...
さらに前回の例から次の
...
JSON
...
文字列を使用します。
...
{ ...
...
"contactNo":
...
[ { area:"02",
...
no:"9378
...
2867",
...
type:"landline"
...
\},
...
{ no:"0468
...
732
...
371",
...
type:"mobile"
...
\}
...
]
最初の連絡先 (contact
...
number)
...
の市外局番
...
(area)
...
へのパスは
...
"contactNo/1/area"
...
です。
...
インデックスは常に1
...
がベースなることに注意してください。これは
...
RDML
...
の基準です。
...
それでは実際にメソッドを使用してみましょう。
...
"given"
...
と
...
"surname"
...
のメンバ値の取得は以下のようになります。
...
#GivenName
...
:=
...
#Reader.ReadStringWithPath("name/given")
...
#Surname
...
:=
...
#Reader.ReadStringWithPath("name/surname")
...
"name"
...
オブジェクトを開いて入ることもできます。こうすれば、パスで
...
"name"
...
のセグメントを繰り返す必要がありません。
...
#Reader.BeginObjectWithPath("name")
...
#GivenName
...
:=
...
#Reader.ReadStringWithPath("given")
...
#Surname
...
:=
...
#Reader.ReadStringWithPath("surname")
...
#Reader.EndObject
...
以下のように、最初の連絡先から連絡先のタイプを取得できます。
...
#ContactNoType
...
:=
...
#Reader.ReadStringWithPath("contactNo/1/type")
...
もしくは、最初に
...
"contactNo"
...
の最初のエレメントにナビゲートし、次に
...
"type"
...
の値を取得することもできます。
...
#Reader.BeginObjectWithPath("contactNo/1")
...
#ContactNoType
...
:=
...
#Reader.ReadStringWithPath("type")
...
#Reader.EndObject
...