Page History
...
例えば、前回の例にあった以下の 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" です。
...
"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
次は: Read…WithName メソッドRead…WithName メソッド