Skip to content

Commit

Permalink
Merge pull request #17 from kak2z7702/fix_json_message
Browse files Browse the repository at this point in the history
Fix parse json format
  • Loading branch information
amranidev authored Feb 26, 2022
2 parents c665925 + 0e64088 commit c39795d
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/Sqs/SqsJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,24 @@ public function payload()

$payload['job'] = $this->handler;

$payload['data'] = unserialize($payload['Message']);
if ($this->isJson($payload['Message']) === true) {
$payload['data'] = $payload['Message'];
} else {
$payload['data'] = unserialize($payload['Message']);
}

return $payload;
}

/**
* @param $message
*
* @return bool
*/
private function isJson($message)
{
$result = json_decode(trim($message, '"'), true);

return is_array($result);
}
}

0 comments on commit c39795d

Please sign in to comment.