June 14, 2012

Meğer iç içe 'with()' deyimi kullanılabiliyormuş...:)

import std.stdio, std.json;

void main()
{
   string veri = `{
                   "aile": {
                           "anne": {
                               "ismi":"Havva"
                           },
                           "baba": {
                               "ismi": {
                                   "ilkadı":"Adem"
                               },
                               "oğlu": {
                                   "ismi":"Kabil"
                               }
                           }
                       }
                   }`;

   with(parseJSON(veri).object["aile"])
   {
       writef("%s'dan olma ", object["anne"].object["ismi"].str);

       with(object["baba"])
       {
           writef("%s'in oğlu: ", object["ismi"].object["ilkadı"].str);
           writefln("%s", object["oğlu"].object["ismi"].str);
       }
   }
}

Çıktısı:
'Havva'dan olma Adem'in oğlu: Kabil'

--
[ Bu gönderi, http://ddili.org/forum'dan dönüştürülmüştür. ]