Ejemplo n.º 1
0
 public function testSerialize()
 {
     $input = $this->generageArray();
     $json = Encode::toJson($input)->on(\Serializers\Events::JSON_SERIALIZE, function ($input) {
         $input['a'] = 'foo';
         $input['g'] = 'bar';
         return $input;
     });
     json_decode($json->load());
     $this->assertEquals(json_last_error(), JSON_ERROR_NONE);
 }
Ejemplo n.º 2
0
 /**
  * Transform to JSON
  *
  * @param array $config - configuration
  *
  * @return \Serializers\Encoders\Json
  *
  * @since 1.0
  */
 public function toJson(array $config = array())
 {
     $jsonp = Encode::toJson($this->toArray(), $config);
     return $jsonp;
 }
Ejemplo n.º 3
0
 /**
  * Parse to JSON and return instance of JSON Encoder
  *
  * @param array $config - configuration
  *
  * @return \Serializers\Encoders\Json
  *
  * @since 1.0
  */
 public function toJSON(array $config = array())
 {
     $json = Encode::toJson($this->data, $config);
     return $json;
 }