original_string: public function jsonSerialize()
      {
          $copy = [];
          foreach ((array)$this as $key => $value) {
              if (!is_string($value)) {
                  $element = $value->getElement();
                  if (is_object($element)
                      and method_exists($element, 'name')
                      and $name = $element->name()
                  ) {
                      $copy[$name] = $value instanceof JsonSerializable ? $value->jsonSerialize() : $value;
                  }
                  $copy[$key] = $value instanceof JsonSerializable ? $value->jsonSerialize() : $value;
              } else {
                  $copy[$key] = $value;
              }
          }
          return $copy;
      }
code: public function jsonSerialize()
      {
          $copy = [];
          foreach ((array)$this as $key => $value) {
              if (!is_string($value)) {
                  $element = $value->getElement();
                  if (is_object($element)
                      and method_exists($element, 'name')
                      and $name = $element->name()
                  ) {
                      $copy[$name] = $value instanceof JsonSerializable ? $value->jsonSerialize() : $value;
                  }
                  $copy[$key] = $value instanceof JsonSerializable ? $value->jsonSerialize() : $value;
              } else {
                  $copy[$key] = $value;
              }
          }
          return $copy;
      }
code_tokens: public function jsonSerialize ( ) { $ copy = [ ] ; foreach ( ( array ) $ this as $ key => $ value ) { if ( ! is_string ( $ value ) ) { $ element = $ value -> getElement ( ) ; if ( is_object ( $ element ) and method_exists ( $ element , 'name' ) and $ name = $ element -> name ( ) ) { $ copy [ $ name ] = $ value instanceof JsonSerializable ? $ value -> jsonSerialize ( ) : $ value ; } $ copy [ $ key ] = $ value instanceof JsonSerializable ? $ value -> jsonSerialize ( ) : $ value ; } else { $ copy [ $ key ] = $ value ; } } return $ copy ; }
docstring: Returns a `json_encode`able hash.
  
  @return array
docstring_tokens: Returns a json_encode able hash .