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); }
/** * 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; }
/** * 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; }