Esempio n. 1
0
 public static function toJson($aThing)
 {
     if (is_object($aThing) && $aThing instanceof ToArrayInterface || is_array($aThing)) {
         $thing = StructUtils::toArray($aThing, true);
     } else {
         $thing = $aThing;
     }
     $json = json_encode($thing);
     if (($error = json_last_error()) != JSON_ERROR_NONE) {
         throw new \Exception("Serializing JSON failed with code {$error}.");
     }
     return $json;
 }
Esempio n. 2
0
 public function mergeInto($aValue)
 {
     StructUtils::mergeInto($this->data, $aValue);
 }