code: public function jsonSerialize()
      {
          $serialized = [
              'message' => $this->getPublicMessage(),
              'code' => $this->getCode(),
          ];
          if ($this->getPrevious() instanceof $this) {
              /** @var static $previous */
              $previous = $this->getPrevious();
              $serialized['previous'] = $previous->jsonSerialize();
          }
          return $serialized;
      }
docs: Return data to be serialised into Json.
  
  The returned data contains the public message and exception code (which
  is likely to be the HTTP status code). It will also include any previous
  Aye Aye Exceptions.
  
  @return array