Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
JsonParser example
$errorMessage
=
json_last_error_msg
(
)
;
if
(
!
(
$context
[
self::DETAILED_ERROR_MESSAGES
]
??
$this
->defaultContext
[
self::DETAILED_ERROR_MESSAGES
]
)
)
{
throw
new
NotEncodableValueException
(
$errorMessage
)
;
}
if
(
!
class_exists
(
JsonParser::
class
)
)
{
throw
new
UnsupportedException
(
sprintf
(
'Enabling "%s" serializer option requires seld/jsonlint. Try running "composer require seld/jsonlint".', self::DETAILED_ERROR_MESSAGES
)
)
;
}
throw
new
NotEncodableValueException
(
(
new
JsonParser
(
)
)
->
lint
(
$data
)
?->
getMessage
(
)
?:
$errorMessage
)
;
}
public
function
supportsDecoding
(
string
$format
)
: bool
{
return
JsonEncoder::FORMAT ===
$format
;
}
}