Skip to content

Allows JSON unserializing to be associative or object #28192

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

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/internal/Magento/Framework/Serialize/Serializer/Json.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ public function serialize($data)
* @inheritDoc
* @since 100.2.0
*/
public function unserialize($string)
public function unserialize($string, $assoc = true)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Such change is not allowed: https://devdocs.magento.com/guides/v2.3/contributor-guide/backward-compatible-development/

Let's first find out whether we need such functionality at all.

{
$result = json_decode($string, true);
$result = json_decode($string, $assoc);
if (json_last_error() !== JSON_ERROR_NONE) {
throw new \InvalidArgumentException("Unable to unserialize value. Error: " . json_last_error_msg());
}
Expand Down