public function __construct($json)
 {
     if ($data = json_decode($json, true)) {
         foreach ($data as $key => $value) {
             if (is_array($value)) {
                 // $value is an array
                 foreach ($value as $k => $v) {
                     $this->{$key}[] = rdapObject::KeyToObject($key, $v);
                 }
             } else {
                 // $value is not an array, just create a var with this value (startAddress endAddress ipVersion etc etc)
                 $this->{$key} = $value;
             }
         }
     } else {
         throw new rdapException('Response object could not be validated as proper JSON');
     }
 }
示例#2
0
 public function __construct($key, $content)
 {
     parent::__construct($key, $content);
     // All data has been stored in an internal array, now put it in the correct object structures
     if (count($this->remarks) > 0) {
         foreach ($this->remarks as $id => $remark) {
             $r = new rdapRemark('remark', $remark);
             $this->remarks[$id] = $r;
         }
     }
     if (count($this->vcardArray) > 0) {
         foreach ($this->vcardArray as $id => $vcard) {
             if (is_array($vcard)) {
                 foreach ($vcard as $v) {
                     unset($this->vcardArray[$id]);
                     $this->vcardArray[] = new vcardArray($v);
                 }
             } else {
                 unset($this->vcardArray[$id]);
                 //var_dump($vcard);
             }
         }
     }
     if (count($this->remarks) > 0) {
         foreach ($this->remarks as $id => $remark) {
             unset($this->remarks[$id]);
             $this->remarks[] = new rdapRemark('remark', $remark);
         }
     }
     if (count($this->roles) > 0) {
         foreach ($this->roles as $id => $role) {
             unset($this->roles[$id]);
             $this->roles[] = new rdapRole('role', $role);
         }
     }
 }