Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use suin/json's encoder in JsonMarshaller. #3

Open
suin opened this issue Jan 4, 2018 · 0 comments
Open

Use suin/json's encoder in JsonMarshaller. #3

suin opened this issue Jan 4, 2018 · 0 comments

Comments

@suin
Copy link
Owner

suin commented Jan 4, 2018

Unmarshalling uses suin/json's decoder.

/**
* @param mixed $data
* @param string $typeExpression
* @return array|object
*/
public function unmarshal($data, string $typeExpression)
{
return (new ConstructorUnmarshaller($this->protocol))->unmarshal($this->decoder->decode($data), $typeExpression);
}

On the other hand, marshalling does not.

/**
* @param array|object $value
* @param int $options
* @return mixed
*/
public function marshal($value, $options = 0)
{
return json_encode((new Marshaller($this->protocol))->marshall($value), $options);
}

Since suin/json's encoder throws exceptions, it would be safer than built-in function, when some errors occur.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant