diff --git a/src/Matcher/Pattern/Assert/Json.php b/src/Matcher/Pattern/Assert/Json.php index afd6b3ad..652db0df 100644 --- a/src/Matcher/Pattern/Assert/Json.php +++ b/src/Matcher/Pattern/Assert/Json.php @@ -16,7 +16,13 @@ public static function isValid($value) : bool return false; } - if (null === \json_decode($value) && JSON_ERROR_NONE !== \json_last_error()) { + $result = \json_decode($value); + + if (\is_float($result) && \is_infinite($result)) { + return false; + } + + if (null === $result && JSON_ERROR_NONE !== \json_last_error()) { return false; } diff --git a/tests/Matcher/JsonMatcherTest.php b/tests/Matcher/JsonMatcherTest.php index 42ebbc3c..fce3376a 100644 --- a/tests/Matcher/JsonMatcherTest.php +++ b/tests/Matcher/JsonMatcherTest.php @@ -244,7 +244,11 @@ public static function positiveMatches() [ '[{"name": "Norbert"},{"name":"MichaƂ"},{"name":"Bob"},{"name":"Martin"}]', '"@array@.repeat({\"name\": \"@string@\"})"' - ] + ], + [ + '{"something": "5e61188283825"}', + '{"something": "@string@"}', + ], ]; }