paquettg / leaguewrap

League of Legend API wrapper
MIT License
68 stars 28 forks source link

[Request] JSON serialization of objects #85

Closed bstadick closed 9 years ago

bstadick commented 9 years ago

Using json_encode on a DTO object fails to serialize it to JSON. Making the class Dto\AbstractDto implement JsonSerializable could solve this issue with minimal effort for PHP >= 5.4.

/**
 * Returns the properties of the object to be serialized to JSON.
 *
 * @return object
*/
public function JsonSerialize()
{
    return $this->info;
}

This may require more work than this to ensure proper serialization of all objects.

dnlbauer commented 9 years ago

Theres also $object->raw() which returns the json response as array.

Bryan notifications@github.com schrieb am Mo., 31. Aug. 2015 06:51:

Using json_encode on a DTO object fails to serialize it to JSON. Making the class Dto\AbstractDto implement JsonSerializable could solve this issue with minimal effort for PHP >= 5.4.

  • line 7: Abstract class AbstractDto implements \JsonSerializable {
  • and implement this function in the class:

/**

  • Returns the properties of the object to be serialized to JSON. *
  • @return object */ public function JsonSerialize() { return $this->info; }

This may require more work than this to ensure proper serialization of all objects.

— Reply to this email directly or view it on GitHub https://github.com/paquettg/leaguewrap/issues/85.